microcontroller 1-1

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 12

INTRODUCTION:

Ultrasonic distance measurement is a popular technique used in various applications such as


robotics, automation, and proximity sensing. It utilizes ultrasonic waves to determine the
distance to an object by measuring the time taken for the waves to bounce back after hitting
the object.

COMPONENTS USED
1. Arduino Uno board
2. Ultrasonic sensor module
3. Jumper wires
4. Breadboard
5. LCD Display with I2C Module

ARDUINO UNO
The Arduino Uno is a microcontroller board based on the ATmega328P. Unlike the
traditional Arduino Uno that uses through-hole components, this version uses surface-mount
technology (SMT) for the microcontroller, making it more compact and slightly different in
terms of component layout. Despite these differences, it retains full compatibility with the
standard Arduino Uno.
Specifications:
Microcontroller: ATmega328P (Surface Mount)
Operating Voltage: 5V
Input Voltage (recommended): 7-12V
Input Voltage (limit): 6-20V
Digital I/O Pins: 14 (6 provide PWM output)
Analog Input Pins: 6
DC Current per I/O Pin: 20 mA
DC Current for 3.3V Pin: 50 mA
Flash Memory: 32 KB (ATmega328P) of which 0.5 KB is used by the bootloader
SRAM: 2 KB (ATmega328P)
EEPROM: 1 KB (ATmega328P)
Clock Speed: 16 MHz

Page 1 of 12
Fig 1 :Arduino UNO

Pin Configuration
Vin: Input voltage pin for external power (7-12V).
5V: Regulated 5V output from the board's regulator.
3V3: 3.3V output with a max current draw of 50 mA.
GND: Ground pins.
IOREF: Provides the voltage reference for the microcontroller.
ATmega328: 32 KB Flash, 2 KB SRAM, 1 KB EEPROM.
Digital Pins (14): Operate at 5V with a maximum of 40mA per pin.
Specialized functions: Serial (0, 1), External Interrupts (2, 3), PWM (3, 5, 6, 9, 10, 11), SPI
(10, 11, 12, 13), LED (13), TWI (A4/SDA, A5/SCL).
Analog Inputs (6): Labeled A0 to A5 with 10-bit resolution.
Reset: Used to reset the microcontroller.

Page 2 of 12
ULTRASONIC SENSOR MODULE
The Ultrasonic Sensor Module works by using sound waves to figure out how far an object
is. The module uses two transducers: one transmits out a high-pitched sound, and the other
receives the sound signal bouncing back from the object. These sensors are cheap, easy to
use, and don't need much power to operate. They can even be used to measure how deep
water is because sound travels through water. The range of measuring distance is from about
2cm to 400cm.
Working Of Ultrasonic Sensor
A 5 volt pulse of at least 10 uS (10 microseconds) in duration is applied to the Trigger pin.
The HC-SR04 responds by transmitting a burst of eight pulses at 40 KHz. This 8-pulse
pattern makes the “ultrasonic signature” from the device unique, allowing the receiver to
discriminate between the transmitted pattern and the ultrasonic background noise.
The eight ultrasonic pulses travel through the air away from the transmitter. Meanwhile the
Echo pin goes high to start forming the beginning of the echo-back signal.
If the pulse in NOT reflected back then the Echo signal will timeout after 38 mS (38
milliseconds) and return low. This produces a 38 mS pulse that indicates no obstruction
within the range of the sensor.
If the pulse IS reflected back the Echo pin goes low when the signal is received. This
produces a pulse whose width varies between 150 uS to 25 mS, depending upon the time it
took for the signal to be received.
The width of the received pulse is used to calculate the distance to the reflected object. The
pulse indicates the time it took for the signal to be sent out and reflected back is to get the
distance so we need to divide your result in half.
Distance= (time x speed)/2.

Page 3 of 12
Fig 2:Timing Digram
Specifications:
Operating Voltage: 5V DC
Operating Current: 15mA
Operating Frequency: 40 kHz
Max Range: 4 meters
Min Range: 2 cm
Measuring Angle: 15 degrees
Trigger Input Signal: 10µs TTL pulse
Echo Output Signal: Input TTL level signal and the range in proportion

Pinout of HC-SR04

Fig 3:Ultrasonic Sensor

VCC (Voltage Supply): The pin provides power to the sensor which is 5 volts (5V).
GND (Ground): This pin is used to connect the sensor to the ground (0V).
Trig (Trigger): The trigger pin is used to initiate the distance measurement. When you send a
short pulse (typically 10 microseconds) to this pin, the sensor will send out an ultrasonic
sound wave. It acts as an Input pin for the Sensor.
Echo: The pin senses the reflected ultrasonic sound wave. It outputs a pulse whose width is
proportional to the time the sound wave takes to bounce back after hitting an object. It acts as
an output pin for the sensor.
Transmitting Transducer: The Transducer transmits eight sound waves pulses of 40khz
frequency.

Page 4 of 12
Receiving Transducer: The Transducer senses the incoming sound pulses reflected by an
object.
Oscillator: It is used to oscillate the internal circuit at a particular frequency to generate the
transmitting ultrasonic signals.
LM324: The LM324 is a general-purpose quad operational amplifier (op-amp) IC that is used
to amplify the received and transmitting signals. Also, it is used as a Comparator or filtering
purposes to filter out unwanted frequency signals.
MAX3232: The IC used to facilitate the serial communication or RS-232 signals (TX, RX,
RTS, CTS, etc.) conversion to TTL/CMOS signals for microcontrollers or digital devices.
Basically, a voltage-level conversion of serial data signals between RS-232 and TTL/CMOS
levels.

JUMPER WIRE:
A jump wire (also known as jumper, jumper wire, DuPont wire) is an electrical wire, or
group of them in a cable, with a connector or pin at each end (or sometimes without them –
simply "tinned"), which is normally used to interconnect the components of a breadboard or
other prototype or test circuit, internally or with other equipment or components, without
soldering.

Fig 4:Jumper Wires

LCD DISPLAY (16X2)


An LCD screen is an electronic display module that uses liquid crystal to produce a visible
image. The 16×2 LCD display is a very basic module commonly used in circuits. The 16×2
translates a display of 16 characters per line in 2 such lines. In this LCD, each character is
displayed in a 5×7 pixel matrix. These displays are mainly preferred for multi-segment light-
emitting diodes and seven segments. The main benefits of using this module are inexpensive;
simply programmable, animations, and there are no limitations for displaying custom
characters, special and even animations, etc

Page 5 of 12
Specifications:
Operating Voltage: 5V
Interface: Parallel
Backlight: LED (usually with an option to control the brightness)
Characters: 32 characters (16 characters per line, 2 lines total)
Character Size: 5x8 dot matrix

Pin Configuration:

Fig 5: LCD Display

VSS (Ground): Connects to the ground of the circuit.


VDD (Power): Connects to +5V power supply.
VO (Contrast): Controls the display contrast. It is typically connected to a potentiometer.
RS (Register Select): Selects command register when low, and data register when high.
RW (Read/Write): Selects read mode when high and write mode when low.
E (Enable): Enables writing to the registers.
D0 to D7 (Data Pins): Used to send data to the display (usually only D4 to D7 are used in 4-
bit mode).

Page 6 of 12
A (Anode): Backlight LED anode (connect to +5V through a current-limiting resistor).
K (Cathode): Backlight LED cathode (connect to ground).

BREADBOARD
A breadboard is a rectangular board with a grid of holes that allows us to build and test
circuits without soldering. It is widely used for prototyping electronic circuits. The holes in a
breadboard are connected in a specific pattern that allows components and wires to be
inserted and interconnected easily.

Fig 6:Breadboard

BLOCK DIAGRAM

Page 7 of 12
WORKING
We use ultrasonic transducers comprising of 1 transmitter and 1 receiver.The transmitter can
deliver 40 KHz ultrasonic sound while the maximum receiver is design to accept only 40KHz
sound waves.When ever an obstacle obstructs the signals of ultrasonic transmitter it reflects
the signal towards the ultra sonic receiver.The program is so written in MC to calculate the
distance getting from ultrasonic module. The time interval between sending the signal and
receiving the echo allows us to calculate the distance to the object using the speed of sound in
air. The distance measurement which is seen on LCD displays the distance in cms or inches.

Fig 7: Ultrasonic distance measurement.

APPLICATION
Ultrasonic sensors are widely used in the industrial sector for precise distance measurement.
For example, in the automotive industry, these sensors play a crucial role in automated
parking systems, helping vehicles gauge the distance to obstacles and park safely.

Page 8 of 12
Obstacle detection and avoidance: Ultrasonic sensors are widely used in robots for
navigating environments and avoiding collisions. By constantly measuring distance to
surrounding objects, robots can adjust their movements accordingly.
Liquid level monitoring: By measuring the distance to the surface of a liquid in a tank,
Arduino can trigger alarms when refill is needed or prevent overflows.
Self-parking cars: Ultrasonic sensors are a core component in car parking assist systems,
helping drivers park safely by measuring distances to obstacles.
Used in RADAR system:.To measure distance without physical contact with measuring
instruments.Used in object detection for security purposes.

APPROXIMATE COST
1.Arduino Uno board 370
2. Ultrasonic sensor module 100
3. Jumper wires 40
4. Breadboard 60
5. LCD Display with I2C Module 250

TOTAL COST 820

CODE
#include <Wire.h>
#include <LiquidCrystal_I2C.h>

LiquidCrystal_I2C lcd(0x27, 16, 2);

#define trigPin A0
#define echoPin A1

Page 9 of 12
Void setup() {
Serial.begin(9600);
pinMode(trigPin, OUTPUT);
pinMode(echoPin, INPUT);
lcd.init();
lcd.backlight();
lcd.clear();
lcd.setCursor(0,0);
lcd.print(“Microcontroller”);
lcd.setCursor(0,1);
lcd.print(“Event”);
delay(5000);
lcd.clear();
}

Void loop() {
Long duration, distance, distanceInch;

digitalWrite(trigPin, LOW);
delayMicroseconds(2);
digitalWrite(trigPin, HIGH);
delayMicroseconds(10);
digitalWrite(trigPin, LOW);

duration = pulseIn(echoPin, HIGH);


distance = (duration/2) / 29.1;

Page 10 of 12
distanceInch = duration*0.0133/2;

Serial.print(“distance: “);
Serial.println(distance);

Lcd.setCursor(0,0);
Lcd.print(“Distance: “);
Lcd.print(distance);
Lcd.print(“ cm”);

Lcd.setCursor(0,1);
Lcd.print(“Distance: “);
Lcd.print(distanceInch);
Lcd.print(“ inch”);

Delay(200);
}

CONCLUSION
Ultrasonic distance measurement using Arduino is a straightforward and effective method for
obtaining accurate distance measurements in various projects. Ultrasonic distance
measurement offers a versatile and accurate solution for various applications requiring non-
contact distance sensing. Through the utilization of ultrasonic sensors and Arduino
microcontrollers, this project aims to demonstrate the fundamental principles and practical
implementation of such technology. By understanding the basics of ultrasonic wave
propagation, time-of-flight measurement, and data processing we can gain insights into
creating effective distance measurement systems.
Looking forward, the knowledge gained from this project can be applied to diverse fields
including robotics, automation, and consumer electronics, where precise distance
measurement is crucial for enhancing functionality and safety.

Page 11 of 12
REFERENCE
https://www.indmall.in/faq/how-does-an-ultrasonic-sensor-measure-distance/
https://how2electronics.com/how-to-use-hc-sr04-ultrasonic-distance-sensor-with-arduino/
https://quartzcomponents.com/blogs/electronics-projects/interfacing-ultrasonic-sensor-hc-
sr04-with-arduino

Page 12 of 12

You might also like