0% found this document useful (0 votes)
12 views4 pages

Experiment 2

The document describes an experiment using an infrared sensor to detect objects and trigger an LED. When the IR sensor detects an object, it outputs a low signal turning on the LED connected to pin 13. If no object is detected, the LED remains off. The code configures pins for the IR sensor and LED and uses if/else statements to control the LED based on the sensor reading.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views4 pages

Experiment 2

The document describes an experiment using an infrared sensor to detect objects and trigger an LED. When the IR sensor detects an object, it outputs a low signal turning on the LED connected to pin 13. If no object is detected, the LED remains off. The code configures pins for the IR sensor and LED and uses if/else statements to control the LED based on the sensor reading.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

of Conduction-17/01/2024

Date of Submission-25/04/2024

Name-SHIVPRIYA GUPTA

PRN-22070123111

E&TC-B2 EXPERIMENT-2

TITLE:
(a)-Simple Digital Input Sensor Control.

AIM:
(a)- The aim of the experiment is to detect and respond to the infrared (IR) sensor input by turning
on an LED (connected to pin 13) when the IR sensor detects an object.

SOFTWARWE AND HARDWARE REQUIRED:


Software Required: Arduino IDE or any other compatible Arduino development environment.

Hardware Required: Infrared (IR) sensor, Breadboards, LED, Resistors, Jumper wires

THEORY:
Functions Used:
pinMode(13,OUTPUT): Configures digital pin 13 as an output to which an LED is typically connected.
pinMode(2,INPUT): Configures digital pin 2 as an input, suggesting that this pin is connected to a
sensor.
: Reads the digital state of pin 2 and stores it in the variable

if (SensorValue == LOW): Checks if the sensor value is LOW, indicating some condition (e.g., an
obstacle) is detected.
If true, it turns on the LED connected to pin 13 by executing digitalWrite(13, HIGH).
else: If the sensor value is not LOW, it turns off the LED by executing digitalWrite(13, LOW).

Sensor Information:
The code assumes the use of an infrared (IR) sensor connected to digital pin 2. IR sensors are
commonly used for obstacle detection. These sensors typically consist of an infrared transmitter (IR
LED) and an infrared receiver. When an obstacle is detected, the infrared light emitted by the
transmitter is reflected back to the receiver, causing the sensor to output a LOW signal.

Signal Conditioning Circuit for IR Sensor:

The IR sensor has three pins: VCC, GND, and OUT. Connect
VCC to a 5V power source on the Arduino. Connect GND
to the ground (GND) on the Arduino. Connect OUT to
digital pin 2 on the Arduino.

The IR sensor emits infrared light, and when it hits an obstacle, the reflected light is
detected by the sensor.
If an obstacle is present, the sensor outputs a LOW signal; otherwise, it outputs a HIGH
signal.

Digital pin 13 is configured as an OUTPUT and connected to an LED.


When the sensor detects an obstacle (LOW signal), the LED on pin 13 is turned ON.
SOURCE CODE:
int SensorValue;
void setup()
{
pinMode(13, OUTPUT);
pinMode(2, INPUT);
}
void loop()
{
SensorValue = digitalRead(2);
if (SensorValue==LOW)
{
digitalWrite(13, HIGH);
}
else
{
digitalWrite(13, LOW);
}
)
INPUT SCREENSHOT:
OUTPUT:

CONCLUSION: This code uses an IR sensor to detect obstacles. When the sensor detects an
obstacle, it outputs a LOW signal, turning on the LED connected to pin 13. If no obstacle is
detected, the LED remains off. The practical implementation involves connecting the IR sensor to
the specified pins on the Arduino and connecting an LED to pin 13 for visual feedback.

You might also like