Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import processing.serial.*;
- Serial myPort; // our serial port
- String string1 = "";
- String string2 = "";
- color bgColor = color( 255 ); // color of background
- void setup() {
- size( 800, 600 );
- background( bgColor ); // set the background color\
- // prints the serial ports so you can choose the correct number below
- printArray(Serial.list());
- // your port will be different to the 11 below
- myPort = new Serial(this, Serial.list()[11], 9600);
- myPort.bufferUntil(10);
- }
- void draw() {
- // loop for displaying on the screen we are not using this here
- textSize(32);
- // display values on screen
- background( bgColor ); // set the background color
- fill(0, 102, 153, 51);
- text(string1, 10, 30);
- text(string2, 10, 60);
- }
- void serialEvent(Serial p) {
- String inString = p.readString(); // read in the string
- String pairs[] = split( inString, ';' ); // split up string into pairs
- println(pairs[0]+","+pairs[1]); // print to the monitor below
- string1 = pairs[0];
- string2 = pairs[1];
- }
Advertisement
Add Comment
Please, Sign In to add comment