reading xbee with processing
in
Integration and Hardware
•
5 months ago
Hi all,
I'm trying to read the data from an xbee into processing. My setup is one arduino fio which sends data to the serial port. On the receiving end I've got an Xbee explorer USB ( https://www.sparkfun.com/products/8687). The connection works as I can view correct data coming in when I use the X-CTU monitor. The values are something like
123, 456
789, 123
etc.
I try to read the data into processing using the SimpleRead example script:
I'm trying to read the data from an xbee into processing. My setup is one arduino fio which sends data to the serial port. On the receiving end I've got an Xbee explorer USB ( https://www.sparkfun.com/products/8687). The connection works as I can view correct data coming in when I use the X-CTU monitor. The values are something like
123, 456
789, 123
etc.
I try to read the data into processing using the SimpleRead example script:
- import processing.serial.*;
- Serial myPort; // Create object from Serial class
- int val; // Data received from the serial port
- void setup()
- {
- size(200, 200);
- String portName = Serial.list()[0];
- myPort = new Serial(this, portName, 9600);
- }
- void draw()
- {
- if ( myPort.available() > 0) { // If data is available,
- val = myPort.read(); // read it and store it in val
- }
- background(255); // Set background to white
- if (val == 0) { // If the serial value is 0,
- fill(0); // set fill to black
- }
- else { // If the serial value is not 0,
- fill(204); // set fill to light gray
- }
- rect(50, 50, 100, 100);
- }
Now when I print 'val' I get very different numbers:
0
0
55
44
53
13
191
0
129
this repeats...
Does anyone know what is going wrong here? Is it possible to read in straight from the USB explorer?
Any help is greatly appreciated. Best, danielle
0
0
55
44
53
13
191
0
129
this repeats...
Does anyone know what is going wrong here? Is it possible to read in straight from the USB explorer?
Any help is greatly appreciated. Best, danielle
1