I have uploaded this sketch into the arduino:
void setup() {
pinMode(2, INPUT);
Serial.begin(9600);
}
void loop()
{
Serial.println(analogRead(2));
}
and the analog pin is connected to the arduino's 5v, which means in the serial port it has to show only numbers around 1023.
though i have tried to read serial data from processing, it gives me numbers lower than 60. here is the processing code:
import processing.serial.*;
Serial myPort;
int val;
void setup()
{
String portName = Serial.list()[1]; //com3, same as arduino
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
println(val);
}
}
what can cause this problem?