Hey guys!
Ive been trying to read multiple sensors from ardunio and get that data into oF
I came across a
useful-post from a while back which works beautifully (thanks theo)… for one sensor.
Naturally theo is using some foreign concept called bitwise operations, to be all clever =D
So i went and researched about these things, and came across a helpful-post which so rather useful for someone whos got the concept down pat.
so for one sensor he has
unsigned char val1;
unsigned char val2;
//gnarly code to turn the int into two bytes
val1 = value &0xFF;
val2 = (value >> 8) &0xFF;
//send both bytes
Serial.print(val1, BYTE);
Serial.print(val2, BYTE);
and then back in oF to convert it back
sensor_01 = ( (unsigned char)bytesReadString[1] << 8 | (unsigned char)bytesReadString[0] );
So while i stumble around and hopefully fluke the right answer, does anyone have some pointers to extend the code to consist of 4 varibles?
Thanks heaps!