Hi guys,
I'm moving my first steps with Arduino.. now I'm trying some reading from the Analog In. This is my circuit: yfrog.com/6ximage217qj
This is my code:
/* read the value from a potentiometer and use it as delay */
int potPin = 0;
int ledPin = 13;
int val = 0;
void setup() {
Serial.begin(9600);
pinMode(ledPin, OUTPUT);
}
void loop() {
val = analogRead(potPin); // read the value from the sensor
digitalWrite(ledPin, HIGH); // turn the ledPin on
Serial.println(val);
delay(val); // stop the program for some time
digitalWrite(ledPin, LOW); // turn the ledPin off
delay(val); // stop the program for some time
}
I don't get why I always get 1023 on serial monitor.
Given that the current flows from 5V to the two resistors I would have expected a decrease in the voltage thus reading something smaller than 1023.
What am I doing wrong? If this has something with wrong circuit stuff, would you point me so some documentation about it?
Thanks,
Fabio Varesano