CNY70 Sensors Line Follower

Hi!
I'm trying to build a simple line follower. To detect the black line over a white surface I use 5 CNY70 sensors (http://www.electronicaembajadores.com/datos/pdf1/ss/ssir/cny70.pdf).

The circuit looks like this
http://2.bp.blogspot.com/-DgKjxBA_j5s/Tk5kDuqXU5I/AAAAAAAAA5Q/U7fgmawtphQ/s1600/CNY70.jpeghttp://2.bp.blogspot.com/-DgKjxBA_j5s/Tk5kDuqXU5I/AAAAAAAAA5Q/U7fgmawtphQ/s1600/CNY70.jpeg

The code (i want to read and print different values with some delay, just to check if it works):

int sensorPin1 = A5;
int sensorPin2 = A4;
int sensorPin3 = A3;
int sensorPin4 = A2;
int sensorPin5 = A1;

int value = 0;

void setup() {
Serial.begin(9600);

pinMode(sensorPin1, INPUT);
pinMode(sensorPin2, INPUT);
pinMode(sensorPin3, INPUT);
pinMode(sensorPin4, INPUT);
pinMode(sensorPin5, INPUT);
}

void loop() {
// read the value from the sensor:
value = analogRead(sensorPin1);
Serial.println("Sensor1:");
Serial.println(value);
delay(800);

value = analogRead(sensorPin2);
Serial.println("Sensor2:");
Serial.println(value);
delay(800);

value = analogRead(sensorPin3);
Serial.println("Sensor3:");
Serial.println(value);
delay(800);

value = analogRead(sensorPin4);
Serial.println("Sensor4:");
Serial.println(value);
delay(800);

value = analogRead(sensorPin5);
Serial.println("Sensor5:");
Serial.println(value);
delay(800);

}

More data:

  • The five sensors are arrange in parallel.
  • I supply with 5v pin.
  • I sink with 1GND pin
  • Each sensor OUTPUT is connected to one analog INPUT in the arduino board

MY PROBLEM:

One by one all sensors work perfect. The problem arises when using all 5 sensors at the same time. Strange things start to happen (read values change with no reason, a sensor which used to work good does no provide right values, .....).

I'm considering it migh be related with max currents supplied/sunk by arduino board.

I would appreciate any suggestion.

Thanks in advance.

Lose all the pinMode calls in setup.

Try reading each sensor twice, and just throw away (overwrite) the first value.

Arrays would be useful here . . .