IR Line tracking sensor example

This is another example using a sensor from the 37 sensor kit, this time we use the one called the KY-033 Hunt sensor module, this looks like thisky-033-sensor-module-

A more correct name would be a IR Line tracking sensor
The sensor has IR light emitter and detector. The sensor returns the status of the IR light reflected from a surface as ON or OFF. The on board LED shows the status of the sensor. You need to calibrate the sensor first, basically block the sensor and adjust the pot until the led goes on. Then remove the object and the on board LED should go off.

here are the connections I used

Sensor Wemos Mini
V+ 3v3



Not overly complex this example, I noticed that using the serial monitor that the value was 559 when no object was present and around 29 when I blocked the sensor so I decided that if the value was under 100 I would switch the built in wemos led off, default being on in this example

[codesyntax lang=”cpp”]

int sensorPin = A0; // select the input pin
int sensorValue = 0; // variable to store the value coming from the sensor

void setup ()
 pinMode(BUILTIN_LED, OUTPUT); // Initialize the BUILTIN_LED pin as an output
 Serial.begin (9600);

void loop ()
 sensorValue = analogRead (sensorPin);
 Serial.println (sensorValue, DEC); //debug
 if(sensorValue <= 100)
 digitalWrite (BUILTIN_LED, HIGH); //led off
 digitalWrite (BUILTIN_LED, LOW); //led on - default






Please enter your comment!
Please enter your name here