0% found this document useful (0 votes)
11 views5 pages

Expriment 2 A

The document describes a code for an obstacle detection system using an Arduino. The code uses an infrared sensor to detect obstacles and illuminates an LED if an obstacle is present while providing serial feedback. It explains the hardware and software used, the theory behind the code operations, and includes the source code.
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)
11 views5 pages

Expriment 2 A

The document describes a code for an obstacle detection system using an Arduino. The code uses an infrared sensor to detect obstacles and illuminates an LED if an obstacle is present while providing serial feedback. It explains the hardware and software used, the theory behind the code operations, and includes the source code.
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/ 5

Conduction-25/01/2024

Submission-25/04/2024

Name-SHIVPRIYA GUPTA

PRN-22070123111

E&TC-B2 EXPERIMENT-2(A)

TITLE:
Obstacle Detection System using Arduino

AIM:
The aim of the code is to detect the presence of an obstacle using a sensor connected to pin 12, and
accordingly, illuminate an LED on pin 13 while providing serial feedback about obstacle
presence.

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:
1. pinMode(pin, mode):

● This function configures the specified pin to behave either as an input or an output.

● Used in the setup() function to configure pins Sensor (pin 12) as an input and LED (pin
13) as an output.

2. digitalRead(pin):

● This function reads the digital state (HIGH or LOW) of a specified pin.

● Used in the loop() function to read the state of the sensor connected to pin 12 (Sensor).

3. digitalWrite(pin, value):

● This function sets the specified pin to the given value (HIGH or LOW), which
corresponds to turning it on or off.

● Used in the loop() function to control the LED connected to pin 13 (LED).

4. Serial.begin(speed):

● This function initializes serial communication with the specified baud rate.

● Used in the setup() function to initiate serial communication with a baud rate of 750.
5. Serial.println(data):

● This function sends data (usually strings or numbers) to the serial port for
communication with an external device (e.g., computer, serial monitor).

● Used in the loop() function to print messages indicating whether an obstacle is present
or not.

Overall, the code continuously checks the state of the sensor connected to pin 12. If the sensor detects
an obstacle (reads LOW), it turns on the LED connected to pin 13 and sends a corresponding message
over the serial port. If no obstacle is detected (reads HIGH), it turns off the LED and sends a different
message over the serial port.

Sensor Information:
● The sensor used in this code is assumed to be an IR obstacle detection sensor or something
similar. These sensors typically output a digital LOW signal when they detect an obstacle and a
HIGH signal when there's no obstacle.

● The exact type and model of the sensor are not specified in the code provided. If you have a
specific sensor, you might need to consult its datasheet or documentation for more detailed
information on its operation and pinout.

Signal Conditioning Circuit for IR Sensor:


IR Sensor is connected to ground (GND) and VCC.

A resistor (R1) is connected between the sensor output and the junction of R2 and C1.

Another resistor (R2) is connected in series with a capacitor (C1).

The junction between R1 and R2, connected to C1, is the conditioned signal output.

Adjust the values of R1, R2, and C1 based on your sensor's characteristics and the desired response time.
This is a basic circuit, and the specific values would depend on the specifications of your IR sensor and
the requirements of your application.

SOURCE CODE:

int Sensor = 12;


int LED = 13;
void setup()
{
pinMode(Sensor, INPUT);
pinMode(LED,OUTPUT);
Serial.begin(750);
}
void loop()
{
Sensor = digitalRead(12);
if (Sensor == LOW)
{
digitalWrite(LED, HIGH);
Serial.println("Obstacle present!!!");
}
else
{
digitalWrite(LED, LOW);
Serial.println("No Obstacle present!!!");
}
}

INPUT SCREENSHOT:
OUTPUT:

Result:
CONCLUSION:

● The code is designed to detect the presence of an obstacle using a digital signal from
the infrared sensor.
● When an obstacle is detected, the LED is turned on, and a corresponding message is
sent to the serial monitor.
● When no obstacle is present, the LED is turned off, and a different message is sent to the
serial monitor.

You might also like