0% found this document useful (0 votes)
278 views10 pages

IR Sensor and LED Integration with Arduino

The document provides instructions for an assignment using an Arduino board to detect obstacles with an IR sensor and notify the user with LEDs. It describes connecting an IR sensor and LEDs to an Arduino board and writing code to detect obstacles using the IR sensor and signal the detection with the LEDs. The assignment objectives are to demonstrate the connectivity of an IR sensor in an Arduino board and to implement a program where the IR sensor detection can notify the user using LEDs.

Uploaded by

callhimsid
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)
278 views10 pages

IR Sensor and LED Integration with Arduino

The document provides instructions for an assignment using an Arduino board to detect obstacles with an IR sensor and notify the user with LEDs. It describes connecting an IR sensor and LEDs to an Arduino board and writing code to detect obstacles using the IR sensor and signal the detection with the LEDs. The assignment objectives are to demonstrate the connectivity of an IR sensor in an Arduino board and to implement a program where the IR sensor detection can notify the user using LEDs.

Uploaded by

callhimsid
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

PART – II

ELECTIVE I

Internet of Things and Embedded Systems

ASSIGNMENT NO: 01

Title: Understanding the connectivity of Raspberry-Pi / Adriano with IR sensor. Write an


application to detect obstacle and notify user using LEDs.
Objectives:

- To demonstrate connectivity of IR sensor in Arduino board


- To implement a program in which IR sensor can be detected and notify by using LED.

Outcomes:

By using Adriano circuit we can implement IR sensor by using LED .

Hardware : MicroATmega328 Microcontroller development Board.

Software: Arduino IDE

Theory:

Introduction To Arduino

Arduino is an open-source platform used for building electronics projects. Arduino consists of both a
physical programmable circuit board (often referred to as a microcontroller) and a piece of software,
or IDE (Integrated Development Environment) that runs on your computer, used to write and upload
computer code to the physical board. Accepts analog and digital signals as input and gives desired
output.

MicroATmega328-ATmega328 Microcontroller Development Board

The MicroATmega328 is a Arduino compatible Hardware Development Platform from


MicroEmbedded Technologies. It is a full featured board for the beginner as well as the expert user
who is accustomed to the Arduino platform and or the ATmega series microcontroller development.
The MicroATmega328 development board retains all the features of the Arduino Uno board and adds
to it additional interfaces like the 16x2 character LCD, on-board LED’s, USB-to-Serial adaptors, 16
key keypad arranged in 4x4 matrix circuit, on-board Temperature sensor, I2C interface Real Time
Clock, external interrupt, Stepper Motor / DC Motor, SPI based flash programming interface, dual
power source, header for accelerometer and also a Arduino Uno board compatible Header to
interface the easily available Arduino Shield boards. All these features make the MicroAtmega328 a
very versatile and a more robust educational tool for the learner as well as the trainer.

Figure 1 Block Diagram of the MicroATmega328 Board

The ATmega328 is a high-performance 8-bit AVR RISC-based microcontroller. It combines 32KB


ISP flash memory with read-while-write capabilities, 1KB EEPROM, 2KB SRAM, 23 general
purpose I/O lines, 32 general purpose working registers, three flexible timer/counters with compare
modes, internal and external interrupts, serial programmable USART, a byte-oriented 2-wire serial
interface, SPI serial port, 6-channel 10-bit A/D converter, programmable watchdog timer with
internal oscillator, and five software selectable power saving modes. The device operates between
1.8-5.5 volts.

The ATmega328 AVR Microcontroller


Figure 2 ATmega328 AVR Microcontroller

Hardware: Functional Description and Interfacing

Light Emitting Diode (LED)


Light Emitting Diode (LED) is a semiconductor device which emits light at a very low power. They
are highly efficient devices and require very low current in order to operate. A voltage of 5v and
current of 10mA is enough to turn the LED on. The LED has a positive side called the Anode and a
negative side called the Cathode. The current must flow from the Anode to Cathode for the LED to
turn on. On the MicroATmega328 board there are 4 LEDs. The LED’s are connected in the common
cathode method, i.e. all the cathodes are connected together and grounded. The individual Anodes
are connected to the individual Pins of the microcontroller. To turn the LED “ON” the user has to
program the port pin to “HIGH” i.e.”1”.
Note: switch SW20 must be in position 2-3 to operate the LED’s.
Figure 3 LED

Table 1 LED Interfacing Details

LED
Device ATmega328 Pin Arduino Pin Description
LED1 PB2 10 Common Cathode
LED
LED2 PB3 11 Common Cathode
LED
LED3 PB4 12 Common Cathode
LED
LED4 PB5 13 Common Cathode
LED

IR Sensor

An infrared proximity sensor or IR Sensor is an electronic device that emits infrared lights to
sense some aspect of the surroundings and can be employed to detect the motion of an object. As
this is a passive sensor, it can only measure infrared radiation.

Features of IR sensor
Consisting of three pins, a potentiometer, and two LEDs, the IR sensor is an electronic device
that emits radiations in order to get a sense of the surrounding. IR sensor has the capability to
measure the heat of the object and can also detect motion. Such types of sensors that get the
sense of the surrounding by only detecting/receiving or absorbing IR radiations rather than
emitting IR radiations are passive IR sensors.
The human eye cannot detect IR radiations but to IR sensor these radiations are visible. At the
end of the module, there are two LEDs. One is RED led which performs the function of the
emitter and the other one is photodiode which works as a receiver. The emitter emits infrared
radiations which after hitting some object receives by the detector photodiode is sensitive only to
the radiations of the infrared region. When the emitted IR radiations fall on the photodiode, it
produces resistance and voltage which is in proportion to the radiations fell upon.

IR Sensor Pinout
The IR sensor has a 3-pin connector that interfaces it to the outside world. The connections are as follows:

VCC is the power supply pin for the IR sensor which we connect to the 5V pin on the Arduino.

OUT pin is a 5V TTL logic output. LOW indicates no motion is detected; HIGH means motion is detected.
GND Should be connected to the ground of the Arduino.

IR Motion Sensor Module – Parts


For most of the Arduino projects, this sensor is used to detect proximity or to build obstacle avoidance robots.
This Sensor is popular among beginners as these are low power, low cost, rugged, and feature a wide sensing
range that can be trimmed down to adjust the sensitivity.

This sensor has three pins two of which are power pins leveled VCC and GND and the other one is the
sense/data pin which is shown in the diagram above. It has an onboard power LED and a signal LED the power
LED turns on when power is applied to the board the signal LED turns on when the circuit is triggered. This
board also has a comparator Op-amp that is responsible for converting the incoming analog signal from the
photodiode to a digital signal. We also have a sensitivity adjustment potentiometer; with that, we can adjust the
sensitivity of the device. Last and finally, we have the photodiode and the IR emitting LED pair which all
together make the total IR Proximity Sensor Module.

ARDINO IDE OVERVIEW

1. To create a new sketchFile -> New


• To open an existing sketch File -> open ->
• There are some basic ready-to-use sketches available in the EXAMPLES section
• File -> Examples -> select any program

Program coded in Arduino IDE is called a SKETCH
2. Verify: Checks the code for compilation errors
3. Upload: Uploads the final code to the controller board
4. New: Creates a new blank sketch with basic structure
5. Open: Opens an existing sketch
6. Save: Saves the current sketch

Serial Monitor: Opens the serial console


All the data printed to the console are displayed here

Figure 4 Structure of Sketch

A sketch can be divided into two parts:


Setup ()
Loop()
The function setup() is the point where the code starts, just like the main() function in C and C++
I/O Variables, pin modes are initialized in the Setup() function Loop() function, as the name
suggests, iterates the specified task in the program
DATA TYPES:
Void ,Long, Int ,Char ,Boolean, Unsigned char ,Byte, Unsigned int, Word ,Unsigned long ,Float,
Double, Array ,String-char array, String-object, Short .
Input/Output Functions:
The arduino pins can be configured to act as input or output pins using the pinMode() function
Void setup ()
{
pinMode (pin , mode);
}
Pin- pin number on the Arduino board Mode- INPUT/OUTPUT
digitalWrite() : Writes a HIGH or LOW value to a digital pin
analogRead() : Reads from the analog input pin i.e., voltage applied across the pin
Character functions such as isdigit(), isalpha(), isalnum(), isxdigit(), islower(), isupper(), isspace()
return 1(true) or 0(false)
Delay() function is one of the most common time manipulation function used to provide a delay of
specified time. It accepts integer value (time in miliseconds)

Program

Write down code which we have implemented in practical and paste screenshot which we have done
in practical.
Input/Output Functions:
The arduino pins can be configured to act as input or output pins using the pinMode() function
Void setup ()
{
pinMode (pin , mode);
}
Pin- pin number on the Arduino board Mode- INPUT/OUTPUT
digitalWrite() : Writes a HIGH or LOW value to a digital pin
analogRead() : Reads from the analog input pin i.e., voltage applied across the pin
Character functions such as isdigit(), isalpha(), isalnum(), isxdigit(), islower(), isupper(), isspace()
return 1(true) or 0(false)
Delay() function is one of the most common time manipulation function used to provide a delay of
specified time. It accepts integer value (time in miliseconds)

Program

Write down code which we have implemented in practical and paste screenshot which we have done
in practical.

Common questions

Powered by AI

The comparator Op-amp is crucial in an IR sensor module as it converts the analog signal received from the photodiode into a digital output signal. This conversion is necessary because the Arduino requires a digital signal to accurately process motion detection. The Op-amp ensures that changes in voltage from the photodiode, due to varying infrared reflection levels from detected motion, are appropriately amplified and compared to a threshold level to produce a clear digital output, indicating motion detection or absence .

In the Arduino IDE, a sketch for obstacle detection is structured into two primary functions: setup() and loop(). setup() initializes pin modes, setting digital pins connected to the IR sensor as INPUT and those linked to LEDs as OUTPUT. loop() contains code that repeatedly checks the sensor's output using digitalRead(); if motion is detected (output is HIGH), digitalWrite() turns on the corresponding LED, signaling an obstacle. This loop ensures real-time sensor monitoring and LED notification based on immediate detection results .

The MicroATmega328 development board offers versatility and robust capabilities that serve both beginners and expert users. Its design retains standard Arduino Uno features while enhancing them with additional interfaces such as a 16x2 LCD, keypad, temperature sensor, and compatibility with various shields, providing an expansive range of functionalities for complex projects. It includes user-friendly features like a dual power source and multiple communication interfaces, facilitating ease of use and more intricate project developments .

Arduino's input/output functions, such as pinMode() and digitalWrite(), are crucial for controlling IR sensors. pinMode() is used to configure the IR sensor's pins as INPUT for data signals. The digitalWrite() function can set the power and logic level on the IR sensor's pins. For instance, when the sensor detects motion, the digitalRead() function can read a HIGH signal and subsequently trigger an output action like lighting an LED to signify detection .

The ATmega328 facilitates LED operation by providing general-purpose I/O lines connected to the LED anodes. By programming the ATmega328 to set these I/O pins to HIGH (5V), the connected LEDs are illuminated because the common cathode method allows current to flow from anode to ground, thus turning the LEDs ON. The board must be configured with switch SW20 in position 2-3 to enable this functionality .

The IR proximity sensor's popularity among beginners stems from its low power consumption, cost-effectiveness, and ruggedness. Its wide sensing range is adjustable, providing flexibility for various applications, while its simple three-pin interface (VCC, GND, OUTPUT) eases integration with microcontrollers. Additionally, onboard LEDs for power and signal status, along with a straightforward design using an IR LED and photodiode pair, make it accessible for developing entry-level electronics projects such as obstacle detection and automated systems .

The MicroATmega328 board is well-suited for educational purposes due to its comprehensive feature set, accommodating a wide array of learning activities from basic to advanced levels. It includes various interfaces such as motors, displays, and communication ports that allow for diverse project development, helping students understand a broad spectrum of electronics concepts. Its compatibility with Arduino shields and extensive support for programming using Arduino IDE make it an accessible entry point for those new to microcontroller programming while offering depth for experienced users to hone advanced skills .

The IR sensor module supports obstacle detection by emitting and receiving infrared radiations. The module consists of an infrared LED (emitter) and a photodiode (receiver) arranged to detect reflected IR signals. When the emitter's IR rays hit an obstacle, they are reflected back and detected by the photodiode, which changes its resistance proportionally to the received IR intensity. This change is converted into a digital signal by the onboard comparator Op-amp, signaling the detection of an obstacle. The module also includes a sensitivity adjustment potentiometer to calibrate the detection range .

When interfacing an IR sensor with Arduino, key considerations include ensuring proper sensor power supply by connecting VCC to the 5V Arduino pin and grounding the GND pin. The data pin must be correctly interfaced with an appropriate digital pin on the microcontroller, configured as INPUT using pinMode(), to read sensor outputs. Sensitivity adjustment via the potentiometer is crucial for tuning the detection range and accuracy. Calibration and testing are also necessary to account for environmental variables like ambient light that could affect sensor performance .

Arduino IDE assists in developing such projects by providing a user-friendly platform for writing, compiling, and uploading code ('sketches') to the Arduino board. The IDE supports basic sketch creation and offers examples for quick starts. Its verification feature checks the code for errors, and the upload feature transfers code to the microcontroller. It also facilitates debugging and device communication through the serial monitor, allowing real-time data observation and interaction .

You might also like