Arduino and infrared reflective sensor

Testing a infrared reflective sensor module.

I set it up with an arduino board, running the following sketch:

int sensorPin = 10;
int value = 0;
int prevval =0;
int count=0;
void setup() {
void loop() {
 value = digitalRead(sensorPin);
 if(value==0 && prevval==1){ // something is dected
 Serial.print("   ");
 Serial.println(value, DEC);

To run this, connect dout on the sensor to digital pin 10 on the arduino, connect + on the sensor to 5V and – to ground.
When the infrared light is reflected back to the detector, the output goes low. The sensitivity can be adjusted using the trim pot, turning it counter-clockwise lowers the sensitivity, i.e. what passes in front must come closer or be more reflective. In addition to watching the serial monitor for changes, there is a led that lights up when something is detected.

To lower the sensitivity, turn ccw, turn cw to increase the sensitivity

Adjustments of the sensor

The sensor module is marked “” and “LOGO-sensor Var1.5”.

This entry was posted in arduino. Bookmark the permalink.