Hi all,
I'm new in trying to use a Arduino Duemilanove adn created a little program that send the values from the analogRead() fuction of port 0 to 4 to the serial. When connecting nothing to the board I get as expected the following result send to the serial:
0##0##0##0##0/end
But when I connect the 5v output of the board to the analog input pin 2 I get:
989##979##1023##1012##1000/end
I expedted to get:
0##0##1023##0##0/end
I don't understand how this can be please help me the total code of the program is:
int val[] = {0, 0, 0, 0, 0};
int analogPin[] = {0 ,1 ,2 ,3 ,4};
int analogPin0 = 0;
int analogPin1 = 0;
int analogPin2 = 0;
int analogPin3 = 0;
int analogPin4 = 0;
int ledPin2 = 2;
int ledPin3 = 3;
int ledPin4 = 4;
int ledPin5 = 5;
int ledPin6 = 6;
int ledPin7 = 7;
int ledPin8 = 8;
int ledPin9 = 9;
int ledPin10 = 10;
int ledPin13 = 13;
int value = LOW; // previous value of the LED
long previousMillis = 0; // will store last time LED was updated
long interval = 1000; // interval at which to blink (milliseconds)
char StrP[ ] = "arduino";
void setup()
{
Serial.begin(9600); // open the serial port at 9600 bps:
pinMode(ledPin2, OUTPUT); // sets the digital pin as output
pinMode(ledPin3, OUTPUT); // sets the digital pin as output
pinMode(ledPin4, OUTPUT); // sets the digital pin as output
pinMode(ledPin5, OUTPUT); // sets the digital pin as output
pinMode(ledPin6, OUTPUT); // sets the digital pin as output
pinMode(ledPin7, OUTPUT); // sets the digital pin as output
pinMode(ledPin8, OUTPUT); // sets the digital pin as output
pinMode(ledPin9, OUTPUT); // sets the digital pin as output
pinMode(ledPin10, OUTPUT); // sets the digital pin as output
pinMode(ledPin13, OUTPUT); // sets the digital pin as output
}
void loop()
{
// here is where you'd put code that needs to be running all the time.
for (int i=0; i <= 4; i++){
val = analogRead(analogPin*);*
_ //Serial.print(val*);
}
//delay(10000);*_
* // check to see if it's time to blink the LED; that is, is the difference*
* // between the current time and last time we blinked the LED bigger than*
* // the interval at which we want to blink the LED.*
* if (millis() - previousMillis > interval) {*
* previousMillis = millis(); // remember the last time we blinked the LED*
* // if the LED is off turn it on and vice-versa.*
* if (value == LOW)*
* value = HIGH;*
* else*
* value = LOW;*
* for (int i=0; i <=4; i++){*
_ Serial.print(val*);
if (i != 4) {
Serial.print("##");
}
}
Serial.print("/end");
digitalWrite(ledPin13, value);
}
}*_