A sensor is a device which detects or measures a physical property and records, indicates or otherwise responds to it.
Digital sensors give us output in the form of HIGH or LOW signal.
When it detects a phenomenon it gives a HIGH output else a LOW output signal.
Few examples of digital sensors are-IR Sensors, Digital Sound Sensors, Digital Temperature Sensors etc.
We will interface an Infrared Sensor module.
It basically works as an obstacle detector.
Let us learn how to interface an IR (infrared) sensor.
Components required:
- IR sensor module 1No.
- Arduino UNO 1No
- Connecting wires.
- Breadboard.
After making the circuit connections dump the code given below.
int irpin = 2;
int ledPin = 13;
int irValue = 0;
void setup()
{
pinMode(ledPin, OUTPUT);
}
void loop()
{
irValue = digitalRead(irpin);
if(irValue==1)
{
digitalWrite(ledPin, LOW);
}
else
{
digitalWrite(ledPin, HIGH);
}
}
In case your module is working opposite just interchange the HIGH and LOW instructions in the code.
As some modules on detection give 1 others 0 as output.
Below is the output of a sound sensor. Since it’s a digital sensor the circuit connections and interfacing code remains the same.
IR sensor has wide applications you can use them for designing counters, obstacle detectors etc.
IR sensor module has an on-board pot which can be used to adjust sensitivity by altering the resistance.
If the comparator and pot are removed from the module the sensor will give us a pure analog signal through which incident light intensity can be measured.
Thinking?
Join our hands-on training courses.
To know more visit us at http://www.sudolearn.com/
Comments