So, I lost my code. So I went and re-did it, with varied results. This time, much better and it didn’t take all day (maybe only a half of one).
Code is in the comments (if not for yours, then for me).
Now, on to do something a little different, but kind of the same….
Processing:
import processing.serial.*;
Serial myPort;
int xPos=1;
void setup(){
size(500, 500);
println(Serial.list()[0]);
myPort = new Serial(this, Serial.list()[0], 9600);
myPort.bufferUntil(‘\n’);
background (0);
}
void draw (){
}
void serialEvent(Serial port){
String inString = myPort.readStringUntil(‘\n’);
if (inString != null){
inString = trim (inString);
float inByte = float (inString);
inByte = map(inByte, 0, 1023, 0, height);
stroke (127, 34, 255);
line (xPos, height, xPos, height-inByte);
if (xPos>=width){
xPos=0;
background(0);
}
else{
xPos++;
}
}
}
and simple Arduino:
void setup(){
Serial.begin(9600);
}
void loop(){
Serial.println(analogRead(A0));
delay(10);
}