Skip to content

Instantly share code, notes, and snippets.

@XiaohanYa
Created March 3, 2017 02:28
Show Gist options
  • Save XiaohanYa/8dc282a399c44a79b23fd60b8992cbbb to your computer and use it in GitHub Desktop.
Save XiaohanYa/8dc282a399c44a79b23fd60b8992cbbb to your computer and use it in GitHub Desktop.
InteractionLab
import processing.serial.*;
Serial myPort;
int valueFromArduino;
void setup() {
size(500, 500);
background(0);
// print(int('a'));// print out=97
//print(char(97));// print out=a
//print(Serial.list());
for (int i=0; i<Serial.list().length; i++) {
println(i+":"+Serial.list()[i]);
myPort= new Serial(this, Serial.list()[2], 9600);
}
}
void draw() {
background(0);
if (myPort.available()>0) {
valueFromArduino=myPort.read();
}
println(valueFromArduino);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment