sending a variable from arduino to processing
in
Integration and Hardware
•
5 months ago
Hi,
I looked at the graph tutorial that shows how to send raw sensor data from the arduino to procesing. What is the syntax when I want to not send raw sensor data but a variable from the arduino to processing?
Should the code look like this on the arduino side?
Serial.println(analogRead(variable));
and like this on the processing side?
myPort = new Serial(variable, 9600);
and what about the below part of the processing code? Is that necessary if I don't want to draw a graph but just use the variable to for example change the color of a square?
void serialEvent (Serial myPort) {
// get the ASCII string:
String inString = myPort.readStringUntil('\n');
if (inString != null) {
// trim off any whitespace:
inString = trim(inString);
// convert to an int and map to the screen height:
float inByte = float(inString);
inByte = map(inByte, 0, 1023, 0, height);
1