Go Down

Topic: AnalogRead gives always 0 but works with Ardu. SW (Read 604 times) previous topic - next topic

salemh

Hi

I am newbie to Arduino and I started with the examples provided by ARDX (temperature) CIRC-10 and it works fine with arduino software.

Now I am trying to do the same thing with processing and try to read analogpin 0 (as I have connected it to analogue 0)

println(arduino.analogRead(0));

it gives me always 0

What am I doing wrong? Thanks

Code:
Arduino arduino;
float myValue;
int temperaturePin = 0;

void setup()
{

println(Arduino.list());
arduino = new Arduino(this, Arduino.list()[1], 115200);
}

void draw()
{
println(arduino.analogRead(temperaturePin));
}

Senso

Thats one pretty wicked code  :-/
There is even no loop() in there..

salemh

With processing u don't need loop, instead u have draw()

Senso

Well, the first entry in the:
Code: [Select]
println([b]Arduino.list()[/b]);
arduino = new Arduino(this, [b]Arduino.list()[1][/b], 115200);

is Arduino.list()[0] and not [1] as it is an array, and the this,Arduino.list() shouldn't be this.Arduino.list()?
Have you set up the baud rate in arduino as the same in the processing code?

salemh

Ok , goodone! but the problem is not there!

I use com[7] wich is Arduino.list()[1]  in this case as I print it the first thing in the code.

I tried many values for the Baud rate and of course 9600 as in the working example via arduin software.

salemh

Found it.

I had to change the value of Baud rate in StandardFirmata as well to 9600.

Go Up