import processing.serial.*; Serial myPort, usbPort; // Create object from Serial class int val; // Data received from the serial port int LF = 10; void setup() { size(200, 200); println(Serial.list()); myPort = new Serial(this, Serial.list()[7], 9600); usbPort = new Serial(this, Serial.list()[0], 9600); } void draw() { while (myPort.available() > 0) { //Expand array size to the number of bytes you expect: // byte[] inBuffer = new byte[4]; // int numread = myPort.readBytesUntil(0xFF, inBuffer); // if ((inBuffer != null) && numread>2) { // val = int(inBuffer[0])+(int(inBuffer[1])<<8); // low bit plus high bit // usbPort.write(inBuffer[0]); // echo data byte to thermostat val = myPort.read(); usbPort.write(val); // converting that reading to voltage, for 3.3v arduino use 3.3 float voltage = val * 5.0 / 1024; float temp = voltage/0.01; // with single +supply, LM34 is 10.0 mV/deg F // for(int i=0;i<4;i++) { // print(int(inBuffer[i])); // print(" "); // } //println(); print(millis()); print(" "); print(val); print(" : "); print(temp); println(" F"); // } } // delay(100); }