user28775: I want to control 4 pins using hexa code like this ff00ff00 (255, 0, 255, 0).
strtol() function works fine with three pins like 00ff00, but when i add two extra caracters to &payload[1] variable like this ff00ff00.
((rgba >> 24) & 0xFF) is equal to 127 when it should be 255.
How to make this work?
each analog pin should be set from 0 to 255
    analogWrite(LED_WHITE,  ((rgba >> 24) & 0xFF));
    analogWrite(LED_RED,    ((rgba >> 16) & 0xFF));
    analogWrite(LED_GREEN,  ((rgba >> 8) & 0xFF));
    analogWrite(LED_BLUE,   ((rgba >> 0) & 0xFF));


    uint32_t rgba = (uint32_t) strtol((const char *) &payload[1], NULL, 16);


user13432: The function strtol() is not able to convert numbers that are larger than LONG_MAX and smaller than LONG_MIN as it uses signed numbers.
You should use the function strtoul() instead (for unsigned long integers). 
Cheers!

28775: <p>I want to control 4 pins using hexa code like this ff00ff00 (255, 0, 255, 0).</p>

<p>strtol() function works fine with three pins like 00ff00, but when i add two extra caracters to &amp;payload[1] variable like this ff00ff00.
((rgba >> 24) &amp; 0xFF) is equal to 127 when it should be 255.
How to make this work?</p>

<p>each analog pin should be set from 0 to 255</p>

<pre><code>    analogWrite(LED_WHITE,  ((rgba &gt;&gt; 24) &amp; 0xFF));
    analogWrite(LED_RED,    ((rgba &gt;&gt; 16) &amp; 0xFF));
    analogWrite(LED_GREEN,  ((rgba &gt;&gt; 8) &amp; 0xFF));
    analogWrite(LED_BLUE,   ((rgba &gt;&gt; 0) &amp; 0xFF));


    uint32_t rgba = (uint32_t) strtol((const char *) &amp;payload[1], NULL, 16);
</code></pre>
 13432: <p>The function strtol() is not able to convert numbers that are larger than LONG_MAX and smaller than LONG_MIN as it uses signed numbers.</p>

<p>You should use the function <a href="http://www.nongnu.org/avr-libc/user-manual/group__avr__stdlib.html#gaea44aa48bda8261f794dcb2d1e7ab2b2" rel="nofollow noreferrer">strtoul</a>() instead (for unsigned long integers). </p>

<p>Cheers!</p>
