Hello,
I am trying to take 5 analogue readings and send them out the serial port followed by an identifier (in this case "break" to mark the end of the 5 reads). however, with only 1 FSR attached to say, analogue input 0 a reading of say, 250 spreads as though the same reading (or there abouts +/- 5) had been taken from all analogue inputs. here's the code:
int PIN_NUM [5];
int READ_VAL;
void setup ()
{
Serial.begin(57600);
for (int i=0;i<5;i++)
{
pinMode(PIN_NUM ,INPUT);
- }*
}
void loop ()
{ - for (int i=0;i<5;i++)*
- {*
analogRead(PIN_NUM );
READ_VAL = analogRead(PIN_NUM );
* Serial.println(READ_VAL>>2, DEC);
_ delay (500);
}
Serial.println("break");
delay (500);
}
I then tried to write it out the long way just to see if it would work and it does (please see below). Could anybody tell me what the reason for the behaviour of the first lot of code please. Shouldn't these two programmes be identical in behaviour? Any help would be much appreciated.
int READ_VAL;
void setup ()
{
Serial.begin(57600);
pinMode(0,INPUT);
pinMode(1,INPUT);
pinMode(2,INPUT);
pinMode(3,INPUT);
pinMode(4,INPUT);
}
void loop ()
{
analogRead(0);_
READ_VAL = analogRead(0);
Serial.println(READ_VAL>>2, DEC);
_ delay (500);
analogRead(1);_
READ_VAL = analogRead(1);
Serial.println(READ_VAL>>2, DEC);
_ delay (500);
analogRead(2);_
READ_VAL = analogRead(2);
Serial.println(READ_VAL>>2, DEC);
_ delay (500);
analogRead(3);_
READ_VAL = analogRead(3);
Serial.println(READ_VAL>>2, DEC);
_ delay (500);
analogRead(4);_
READ_VAL = analogRead(4);
Serial.println(READ_VAL>>2, DEC);
_ delay (500);
Serial.println("break");
delay (500);
}*_