KY-033 Hunt sensor module arduino example

The KY-033 Hunt sensor module detects if a light reflecting or absorbing area is in front of it. This module uses an IR transmitter and receiver that will detect how reflective the surface is in front of the module. It has a potentiometer to adjust the sensitivity of the module so it can detect if the surface is black or white.

Operating voltage: 2.5V – 12V(cannot over 12V)
Working current: 18mA – 20mA at 5V
Output electrical level signal: low level when detecting objects / high level when no objects / 0 or 1 decides if objects exist

This behavior can be used to automatically follow a line with a robot and this is a very common application of this module

Parts List

Name Link
Arduino Uno UNO R3 CH340G/ATmega328P, compatible for Arduino UNO
Sensor kit 37 IN 1 SENSOR KITS FOR ARDUINO HIGH-QUALITY FREE SHIPPING (Works with Official for Arduino Boards)
connecting wire Free shipping Dupont line 120pcs 20cm male to male + male to female and female to female jumper wire

 

Connection

This is the connections we used

Connect the module’s Power line (middle) and ground (G) to +5v and GND. Connect the signal pin (S) to pin 3¬†on the Arduino.

KY-033 module Arduino connection
S D3
V+ +5V
G GND

Code

int Sensor = 3; // sensor input pin
 
void setup ()
{
  Serial.begin(9600); // Initialize serial output
  pinMode (Sensor, INPUT) ;
}
 
 
void loop ()
{
  bool val = digitalRead (Sensor) ; // The current signal of the sensor will be read
 
  if (val == HIGH)
  {
    Serial.println("Line detected");
  }
  else
  {
    Serial.println("Line not detected");
  }
  Serial.println("------------------------------------");
  delay(500); // 
}

Output

Open the serial monitor and move the IR tracker on and off a black mark, you should see something like this

Line not detected
————————————
Line not detected
————————————
Line not detected
————————————
Line detected
————————————
Line detected
————————————
Line detected
————————————
Line not detected
————————————