I have a senor connected to an Arduino Duemilanove board. I was quite happliy sending the data from the board to a pc wirelessly (via XBee pro modules) using:
int sens0 = 0;
int val1 = 0;
void setup()
{ Serial.begin(19200); //initializes serial port with a baudrate of 19200bps (same as XBee chip)
}
void loop()
{
val1 = (((analogRead(sens0)*1.515*50)/1024)-10);
Serial.print(val1);
delay(5000);
}
I now what to read the data into Processing, but don't seem to be able to do so.
I have uploaded Firmata to the Arduino (which I gather you are meant to do) and I am using the following code in processing but get nothing out:
import processing.serial.*;
import cc.arduino.*;
Arduino arduino;
int sensorPin = 0; // Analog input pin
int sensorValue = 0; // value read from the sensor
void setup()
{
//println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[1]); // v2
// arduino = new Arduino(this, Arduino.list()[0], 9600); // v1
arduino.pinMode(sensorPin, Arduino.INPUT);
}
void draw()
{
sensorValue = arduino.analogRead(sensorPin); // read the sensor value
println(sensorValue); // print the sensor value
delay(5000); // wait 10 milliseconds
// before the next loop
}
What is it that I am doing wrong?