Introduction:
IR sensor is an electronic device that emits certain radiations so as to detect happenings in the environment. Each body radiates thermal radiations which are invisible to human eye but these radiations can be detected IR sensor. IR sensors can detect thermal radiations as well as the motion of human body.
The Emitter in IR sensor is simply an IR LED which emits IR radiations and Detector is an IR photodiode which is sensitive to IR radiations. Whenever photodiode detects any radiation, resistance and output voltages are changes with respect to magnitude of the received IR radiation.
Usage:
IR sensor are being used in wide variety of areas but the main area of focus are: Sensing and Remote control, Robotics, Optical communication, Home Automation.
Application:
Project for Reference:
Measure Distance Using IR Proximity Sensor
Code:
/*
AnalogReadSerial
Reads an analog input on pin 0, prints the result to the serial monitor.
Graphical representation is available using serial plotter (Tools > Serial Plotter menu)
Attach the center pin of a potentiometer to pin A0, and the outside pins to +5V and ground.
This example code is in the public domain.
*/
// the setup routine runs once when you press reset:
void setup() {
// initialize serial communication at 9600 bits per second:
Serial.begin(9600);
pinMode(13,OUTPUT);
pinMode(10,OUTPUT);
digitalWrite(10,LOW);
}
// the loop routine runs over and over again forever:
void loop() {
// read the input on analog pin 0:
int sensorValue = analogRead(A0);
// print out the value you read:
Serial.println(sensorValue);
if(sensorValue<500)
{
digitalWrite(13,HIGH);
}
else
{
digitalWrite(13,LOW);
}
delay(1); // delay in between reads for stability
}
No comments:
Post a Comment