Infrared Sensor with KY-032
If you've read our previous blog posts, then you might be familiar with the different types of UV sensors. This IR Sensor can sense just like a UV Sensor, except the IR Sensor is less efficient. The IR sensor sends out longer wavelengths, so the IR sensor uses infrared sensor. The UV sensor uses smaller wavelengths, basically ultraviolet rays to detect objects. In this case, we are using the KY-016 module for Arduino which uses IR Rays.
Code:
int ledPin = 13; // LED pin on arduino
int detectorPin = 3; // obstacle avoidance sensor interface
int val; // variable to store result
//int enablePin = 2; // sensor enable interface (EN)
void setup()
{
pinMode(ledPin, OUTPUT); // Define LED as output interface
pinMode(detectorPin, INPUT); // Define obstacle avoidance sensor as input interface
// [uncomment and remove jumper on module to use enable pin (EN)]
//pinMode(enablePin, OUTPUT);
//digitalWrite(enablePin, HIGH); // Enable sensor
}
void loop()
{
val = digitalRead(detectorPin); // Read value from sensor
if(val == LOW) // When the sensor detects an obstacle, the LED on the Arduino lights up
{
digitalWrite(ledPin, HIGH);
}
else
{
digitalWrite(ledPin, LOW);
}
}
Source: Arduinomodules.info
Q
Wiring
The wiring is shown below:
This blog and experiment is inspired from Arduinomodules.info and written by
Avviin Chandrasekaran, 8th Grade Student at Kennedy Middle School, Cupertino
California.
Avviin is interested in learning Science and computer concepts and programming.
He was doing Scratch programming from 7 year old and made multiple Youtube
Videos.
0-=-
Comments
Post a Comment