Processing will only show values from 0 to 255
I send the value of 10 to 1023 from Arduino via Serial.write to Processing (via USB). Processing will only show values from 0 to 255. I tried a lot, but I'm stuck.
Any reason processing will only show 0 to 255?
Arduino Code, will output 10 to 1023:
int stopBeingLimited; //create a varable named stopBeingLimited
void setup() {
Serial.begin(9600);
}
void loop() {
stopBeingLimited = analogRead(A0);//get data from the analog pin
Serial.write(stopBeingLimited); // Write the data to the serial communication port
//Serial.println(stopBeingLimited); // show the val data in the serial monitor. DONT USE serial write and serial Print AT THE SAME TIME
delay(100); // Wait 100 milliseconds
}
Processing code, will output 0 to 255 (and jumps from 255 to 0):
import processing.serial.*;
Serial myPort; // Create object from Serial class
int stopBeingLimited; // Data received from the serial port
void setup()
{
size(800, 800);
String portName = Serial.list()[1];
myPort = new Serial(this, portName, 9600);
}
void draw()
{
if ( myPort.available() > 0) { // If data is available,
stopBeingLimited = myPort.read(); // read it and store it in val
}
println(stopBeingLimited);//for debugging
}
You can see this in action, jump to the "But the value jumps to another ‘range’" in the bottom of my page: http://fabacademy.org/2020/labs/waag/students/harm-vanvugt/posts/2020/04/15/week12.html