Sirius Company

IR White & Black Sensor

TCRT Sensor
 

IR Sensor Connection

Vcc: Circuit power pin - connect to +5V on Arduino board.

GND: Circuit ground pin - connect to GND on Arduino board.

A0: Circuit output pin - connect to Analog pin on Arduino board.




 

IR Sensor Arduino Code

int val = 0;

void setup()

{

Serial.begin(9600);

  pinMode(A0,INPUT);

}

void loop()

{

delay(500);

  val = analogRead(A0);

  val = map(val,0,1023,255,0);

  delay(1000);

  Serial.println(val);

  if (val < 10)

{

   Serial.println("BLACK!");

}

else

{

   Serial.println("WHITE!");

}

}