...
We can repeat this process, in combination with the shift right operator to extract all the values:
Code Block | ||
---|---|---|
| ||
// unsigned int RGBAvalue = #FF00FF00 //In reality, we might get thisthe RGBAvalue value from serial or BLE unsigned int RGBAvalue = #FF00FF16 // binary: 11111111000000001111111100010101 byte RED = RGBAvalue >> 24; // binary: 11111111 byte GREEN = RGBAvalue >> 16; // binary: 00000000 byte BLUE = RGBAvalue >> 8; // binary: 11111111 byte ALPHA = RGBAvalue; // binary: 00010101 |
P5js / javascript code
But how do will combine the values to start with, before we seperate them on the Arduino? Here we are assuming that you want to do that on your computer, in a P5js web application that might use serial, BLE, or wifi to communicate with Arduino.
...