Go Down

Topic: multiple analog inputs (Read 467 times) previous topic - next topic

turok

Hi,

I'm making a beginners mistake I guess :)



Code: [Select]
int pot1 = 0; //sensor 1
int pot2 = 0; //sensor 2
int pot3 = 0; //sensor 3
// Value read from moist sensor
int val1 = 0;
int val2 = 0;
int val3 = 0;


void setup()
{
 
pinMode(9, OUTPUT);
  pinMode(10, OUTPUT);
  pinMode(11, OUTPUT);
  pinMode(12, OUTPUT);
  pinMode(13, OUTPUT);
 
Serial.begin(9600);}

void loop()
{
val1 = analogRead(pot1);
Serial.println(val1,DEC);
delay(10);

val2 = analogRead(pot2);
Serial.println(val2,DEC);
delay(10);

val3 = analogRead(pot3);
Serial.println(val3,DEC);
delay(10);

  if(val2 < 300);
{
digitalWrite(9, HIGH);
}
   
  delay(2000);
}


I can read 1 sensor no problem, but when I connect more than one, I always get the value of 1 sensor, but my serial monitor gives me 3 exact the same values (the value of the one sensor it read before)

I think it's the way I wired it... isn't it?

dirk

turok

nevermind sorry,

I just spotted my program error
I was reading pin 0 only

thanks anyway

dirk

Go Up
 


Please enter a valid email to subscribe

Confirm your email address

We need to confirm your email address.
To complete the subscription, please click the link in the email we just sent you.

Thank you for subscribing!

Arduino
via Egeo 16
Torino, 10131
Italy