I am trying to display the values i get from reading a potentiometer (0-1023) in the program called 'processing'.
when I just use Serial.write(integer) and display the value on a line graph in 'processing' the line will max out at 256 and loop back around to 0 as i vary the potentiometer.
I understand that this is because the serial.write can only write in bytes(8 bits) so I would need to package the 16 bit integer into 2 bytes.
i was considering using a union but as you can probably guess i am very new to arduino so i haven't been able to make that work.
here is the code i have tried:
union Data{ uint16_t now; } data;
void setup() { // put your setup code here, to run once:
Serial.begin(9600);
pinMode(A1, INPUT);
}
void loop() { // put your main code here, to run repeatedly:
uint16_t sensorVal = analogRead(A1);
union Data data;
data.now = sensorVal;
Serial.println(data.now);
//Serial.write(sensorVal);
delay(10); }