IR Sensor by Using LED For Arduino

Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

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.

You might also like