Pages: [1]   Go Down
Author Topic: multiple analog inputs  (Read 394 times)
0 Members and 1 Guest are viewing this topic.
Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

Hi,

I'm making a beginners mistake I guess smiley



Code:
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
Logged

Belgium
Offline Offline
Newbie
*
Karma: 0
Posts: 26
View Profile
 Bigger Bigger  Smaller Smaller  Reset Reset

nevermind sorry,

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

thanks anyway

dirk
Logged

Pages: [1]   Go Up
Jump to: