...
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 or , BLE, or wifi to communicate with Arduino.
Code Block | ||
---|---|---|
| ||
|
...
const |
...
buffer |
...
= |
...
new ArrayBuffer(4); // |
...
create |
...
a |
...
4 |
...
byte |
...
buffer |
...
to |
...
store |
...
values |
...
const |
...
view = new |
...
DataView(buffer); // dataview allows reading and writing without having to care about the platform's endianness. view.setUint8(0, Red); view.setUint8(1, Green); view.setUint8(2, Blue); view.setUint8(3, Alpha); let bufferToSend = view.getUint32(); |