 |
Author |
Topic: PIC chip serial variables (Read 243 times) |
|
Zander024

|
PIC chip serial variables
« on: Nov 9th, 2004, 6:29pm » |
|
Ive been trying to take in serial data from a PIC chip, which is working, but for some reason, I cant use that data really as a variable. Right now I have a pressure sensor working, and Processing spits out the correct pressure values when I have it print ln, but when I try to set even a simple variable, like x coordinates or even bg color, the program just seizures and doesnt really go anywhere. I just took the built in program for analog input and added a variable for background. heres the code: String buff = ""; int val = 0; int NEWLINE = 10; void setup() { size(200, 200); beginSerial(9600); } void loop() { } void serialEvent() { if(serial != NEWLINE) { buff += char(serial); } else { buff = buff.substring(0, buff.length()-1); background(val); val = Integer.parseInt(buff)/4; println(val); buff = ""; } } Any Ideas?
|
|
|
|
|