You are on page 1of 21

ASSIGNMENT

Course Code 19ECC214A


Course Name Microprocessors and Microcontrollers
Programme B. Tech.
Department Electronics and Communication
Faculty FET

Name of the Student ABID AZIM C M


Reg. No 18ETEC004004
Semester/Year 4th Sem

Course Leader/s Mr. Vishwanath K Reddy


1

Declaration Sheet
Student Name ABID AZIM C M
Reg. No 18ETEC004004
Programme B. Tech. Semester/Year 4th SEM
Course Code 19ECC214A

Course Title Microprocessors and Microcontrollers


Course Date 06.01.2020 to 18.04.2020
Course Leader Mr. Vishwanath K Reddy

Declaration

The assignment submitted herewith is a result of my own investigations and that I have
conformed to the guidelines against plagiarism as laid out in the Student Handbook. All sections
of the text and results, which have been obtained from other sources, are fully referenced. I
understand that cheating and plagiarism constitute a breach of University regulations and will
be dealt with accordingly.

Signature of the
Date 29/05/2020
Student

Submission date stamp


(by Examination & Assessment
Section)

Signature of the Course Leader and date Signature of the Reviewer and date

Contents
____________________________________________________________________________

2
Microprocessors and Microcontrollers
Declaration Sheet ...................................................................................................................................... 2
Contents .....................................................................................................................................................
3
Question No. A .............................................................................................Error! Bookmark not defined.
A 1 Need/Importance: ........................................................................................................................... 4
A 2 Overview: .........................................................................................................................................
4
A 3 Design & Working: ........................................................................................................................... 5
A 4 Arduino Program & Circuit: ........................................................................................................... 15
A 5 Simulation: .....................................................................................................................................
17
A 6 Coursera Certificates: .................................................................................................................... 18

3
Microprocessors and Microcontrollers
Social Distancing Monitoring Device

Registration No. Name Work

18ETEC004004 Abid Azim C M Ultra-Sonic Sensor

18ETEC004014 Anik Saha NeoPixel & Buzzer

18ETEC004022 Chetan P G NeoPixel & Buzzer

18ETEC004035 Gagan Gundala Arduino Integration

A 1 Need/Importance:
The world is having unprecedented times. We are all battling Coronavirus in one way or another but the
best way for us stay safe is to stay away. After all, prevention is better than cure. Our project applies the
idea of Social Distancing via the Technological Aspect.

The project demonstrates the underlying idea of how technology can play a part in social distancing. A
much more complex, compact and cost-effective model could be developed which can be integrated on
IoT and personal devices like smartphones, smart watches etc. so that it is more feasible for common
public as well as frontline workers.

The post-corona world will not be same as before. There will be new commonly practiced norms like
regular widespread use of masks, social distancing etc. This project can be evolved into a more profitable
device like crowd density monitoring which can be installed in public places. This project can be
improvised with more advanced boards like Dragonboard 410c, Udoo x86 etc.

A 2 Overview:
Our Project is built on Arduino Uno Microcontroller. The social distancing device uses Ultra Sonic sensor
that measures the distance which is then processed using Microchip ATmega328P mounted on Arduino.
Post processing, the suitable actions are implemented using actuators like NeoPixel LEDs, & Buzzer.

Components: Arduino Uno, Ultra Sonic Sensor (HC-SR04), Piezo Buzzer, NeoPixel Strip 20, Breadboard &
Resistors.

4
Microprocessors and Microcontrollers
The Processing Logic is based on Distance. The WHO recommended safe distance is 1.5 meters but for
our purpose we will be taking 130cms as a minimum safe distance. The LEDs light up based on distance,
closer the person is, more red LEDs light up and further the person, more green LEDs light up.
When the distance is less than 130 cms, the buzzer is set off, and all LEDs light up Red.

A 3 Design & Working:

Integration with Arduino (by Gagan G)

Circuit: Integration of different parts worked by other team members was done circuit and code wise.
All the components used supported +5V supply and hence we didn’t need a voltage regulation circuit. A
breadboard was used to provide common line of Ground & Power to the all components. NeoPixels LED
Strip was connected to Pulse Width Modulation (PWM) pin. Although our application does not need
PWM since the LEDs only turn one and off but it would helpful in the future if we decide to tweak the
code to use LEDs as warnings by increasing or decreasing brightness.

Code: The code starts with declaration of variables and pins used. The variables are declared outside
loop() function because we want avoid re-initialization of variables where the Arduino would need to
de-allocate and re-allocate memory address for every iteration of loop() which is a waste of time and
energy. The setup() functions sets up the NeoPixel LEDs. The loop() function consists of 4 lines, each line
calling a function. In this way it is easy for someone to get a good understanding of what the code does
with just a single look at the main function. The code is written in a very simple and understandable way.
Good programming practices were used. The function set_lights() lights up NeoPixel 20 LED strip based
on distance. The logic is simple for lighting up LEDs, for every 10cms distance over 130 cms, one Green
LED is lit up and other remaining LEDs out of 20 LEDs are lit up RED.
If distance goes over 330cms then all LEDs are lit up green.

5
Microprocessors and Microcontrollers
Neopixel LEDs (by Anik Saha)

About Neopixel LEDs

The NeoPixel LEDs are RGB LED lights with a built driver IC that makes these lights addressable and
programmable. The idea was originally coined by Adafruit and since then there are many types of
Neopixels of varying sizes and shapes available in the market. These are individually addressable LEDs
all housed on a string that can be controlled from a single pin on a microcontroller. This means one
pin can control all of the LEDs colors and which LEDs are on at any given time. When compared to a
normal RGB LED it is observed that we need 3 pins to control the Red Green and Blue value and all
LEDs have to remain on or off. So using individually addressable LEDs can help create some cool
effects.
Lots of companies sell strips of addressable LEDs however the most popular is the NeoPixel by
Adafruit. Adafruit produces a line of addressable LED strip and also supplies the library to control them,
this is called "Adafruit NeoPixel", there are other companies that have produced libraries to control
these addressable LEDs however, in my opinion, I've found that Adafruit has the best support and is
the easiest to get started on. Also. we need to have the Arduino IDE installed on our Computer to use
the Neopixel library.

Connections to The Arduino

6
Microprocessors and Microcontrollers
Fig: Circuit diagram for Neopixel LED Connection

• Our first step is to hook up our NeoPixels to the Arduino. I’m using a strip of NeoPixels that has
20 LEDs on them.
• First, connect the ground wire of the NeoPixels to one of the ground pins on the Arduino (GND).

• Then hook the power wire to the +5V pin on the Arduino. Since we’ll only be driving one LED,
the Arduino will be able to power it just fine.

• But microcontroller outputs can only drive a limited amount of current and if we were to try and
drive a large number of LEDs or something more current intensive like a motor, we would have
to use an external power supply.

Logic/ Working of The Code Used To Light The Neopixel Leds

At the very top of our program ,we have the following code:
#include <Adafruit_NeoPixel.h>
This tells the Arduino that we want to use the NeoPixel and all the properties it brings in this sketch, the
sketch would not function without this.

Next, we see a very important line of code:

7
Microprocessors and Microcontrollers
Const int pingPin=7;
The variable named "pingPin" is used to tell the sketch which pin we want to use on the
microcontroller. If we wanted our NeoPixel to be controlled from pin 5 on the microcontroller we
would need to change "7" to "5".
Adafruit_NeoPixel strip = Adafruit_NeoPixel( no_of_leds, neopixel_pin, NEO_GRB + NEO_KHZ800);

This code doesn't really serve a purpose for us, it’s there to help the microcontroller communicate with
the NeoPixel
Now we see the Void Setup:
void setup() {
strip.begin(); strip.show();
}
"strip.begin" is important as this tells the sketch to initialize the library.
“strip.show" sends the current settings to the pixel, if we didn’t have this it would never update the pixel
and it would stay the same.

Next, we see the Void Loop. This is where everything interesting happens.
strip.setPixelColor(i, 0,255,0));

The code starts out with "strip.setPixelColor" and this code is going to allow us to change the color of
the Pixel. The first value is "i", now this is the part of the code were we tell it exactly which pixel we
want to be lit up, right now its set to "i” but if we change this value from "i" to "3" and then upload the
code the third pixel on the string will light up. This is how we control individual pixels.
After this we see “(0, 255, 0)" these are the values we change to change the color.Right now the values
are set to "(0, 255, 0)" which means the strip will be light green (0 means the color is off and 255 is the
brightest the color can go). If I were to change this to "(0, 0, 255)" and upload it the strip would then
become very bright red. Thus, use the strip.setPixelColor() function to turn the LED on and off. The strip
is zero-indexed, so the first pixel is 0. To set the first pixel red, we would set it to a value of (255, 0, 0)
and to turn it off, we would set it to (0, 0, 0) . Again, we have to call strip.show() after each call to
actually change the value of the LED. Finally, we put a delay(100) in between the setPixelColor() calls to
blink the LED.

As shown in the program, a repeating loop for( i=i-1;i<20;i++) has been used to facilitate the LED lighting
of the device with respect to the distance measured.

8
Microprocessors and Microcontrollers
Ultrasonic Sensor (by Abid Azim)

About Ultrasonic Sensor

An ultrasonic sensor is an instrument that measures the distance to an object using ultrasonic sound
waves. Ultra-sonic sensing is one of the best ways to sense proximity and detect levels with high
reliability. An ultrasonic sensor uses a transducer to send and receive ultrasonic pulses that relay back
information about an object’s proximity. High-frequency sound waves reflect from boundaries to
produce distinct echo patterns.

9
Microprocessors and Microcontrollers
Ultrasound is reliable in any lighting environment and can be used inside or outside.
Ultrasonic sensors can handle collision avoidance for a robot, and being moved often, as long as it isn’t
too fast. Ultrasonic are so widely used, they can be reliably implemented in grain bin sensing
applications, water level sensing, drone applications and sensing cars at your local drive-thru restaurant
or bank.

Ultrasonic sensor working:


Ultrasonic sensors work by sending out a sound wave at a frequency above the
range of human hearing. The transducer of the sensor acts as a microphone to receive and send the
ultrasonic sound. Our ultrasonic sensors, like many others, use a single transducer to send a pulse and
to receive the echo. The sensor determines the distance to a target by measuring time lapses between
the sending and receiving of the ultrasonic pulse.
The working principle of this module is simple. It sends an ultrasonic pulse out at
40kHz which travels through the air and if there is an obstacle or object, it will bounce back to the sensor.
By calculating the travel time and the speed of sound, the distance can be calculated.
Calculation of the distance with example:
Suppose the targeted distance is 45cm apart from the ultrasonic sensor then, Time of
Flight is the time required for the ultrasonic sound wave to two times the targeted distance i.e. once
from sensor to the target ad then again bounce back from the target to the sensor.
Time of Flight = 2610 μs = 2.610 ms
Speed of Sound = 58 µs/cm = 0.058 ms/cm
Range (cm) = Time of Flight / Speed of Sound
Range (cm) = (2610 µs) / (58 μs/cm) = (2.610 ms) / (0.058 ms/cm)
Range = 45 cm

Why choose ultrasonic sensor for our project?

Ultrasonic Sensors which are also known as proximity sensors are best used in the non-contact detection
of presence level position and distance which makes it very reliable for our application as corona virus
mainly spreads through contact and through minute particulates through air when they are closer to the
subject. Ultrasonic sensor is also independent of the environmental and other external conditions like
light, smoke, Dust, Colour, material etc. which makes it suitable for external wear while going outside in
the current pandemic.

Other applications of the ultrasonic sensor:

10
Microprocessors and Microcontrollers
Ultrasonic Distance Measuring.
People Detection with Ultrasonic Sensors.
Tank level measurement, Fuel gauging, irrigation control.
Ultrasonic Obstacle Detection.
Autonomous Navigation and Obstacle Avoidance with Ultrasonic Sensors.
Best Ultrasonic Sensor for Indoor Mobile Robotics.

The connections for the ultrasonic sensor with the Arduino are as follows:

Connect VCC on the ultrasonic sensor to the 5V pin on the Arduino.


Connect the Trig pin on the ultrasonic sensor to pin 2 on the Arduino.
Connect the Echo pin on the ultrasonic sensor to pin 3 on the Arduino.
Connect the GND on the ultrasonic sensor to GND on the Arduino.

Explanation of the code used in Arduino project (ultrasonic part)

First of all, we initialized the trigger pin and echo for the ultrasonic sensor. The signal pin is connected to
7 and We have connected the trigger pin to pin 2 on the Arduino and echo pin to pin 3 on the Arduino.
Therefore, we initialized these pins in the code. Then we initialized the variable which will help us in
calculating the distance.

11
Microprocessors and Microcontrollers
In the loop first you have to make sure that the trigPin is clear so you have to set that pin on a LOW State
for just 2 µs. Now for generating the Ultra sound wave we have to set the trigPin on HIGH State for 5 µs.
Using the pulseIn() function you have to read the travel time and put that value into the variable
“duration”. This function has 2 parameters, the first one is the name of the echo pin and for the second
one you can write either HIGH or LOW. In this case, HIGH means that the pulsIn() function will wait for
the pin to go HIGH caused by the bounced sound wave and it will start timing, then it will wait for the
pin to go LOW when the sound wave will end which will stop the timing. At the end the function will
return the length of the pulse in microseconds.

In the setup function, we declare the trigger pin as the output pin because we will send the ultrasonic
wave through that pin. We made the echo pin as input pin because we will receive the ultrasonic wave
through the echo. Then we made a condition that if the distance value is less than or equal to 10, then
the buzzer will start to beep. If the distance value is greater than 10, then the buzzer will remain quiet.

This part of the code converts the time taken by the signal to distance using the formula mentioned in
the ultrasonic part of the project and stores it in distance variable which will be later used to the LED’s
and buzzer action.

12
Microprocessors and Microcontrollers
Piezoelectric (by Chetan P G)
Introduction
Ahh, noise….Birds make it, kids make it – it can be music to our ears or pure torture.We are going to use
a piezo buzzer to make some noise with Arduino.
A piezo buzzer is pretty sweet. It’s not like a regular speaker that you might think of. It uses a material
that’s piezoelectric, it actually changes shape when you apply electricity to it. By adhering a piezo-electric
disc to a thin metal plate, and then applying electricity, we can bend the metal back and forth, which in
turn creates noise.The faster you bend the material, the higher the pitch of the noise that’s produced.
This rate is called frequency. Again, the higher the frequency, the higher the pitch of the noise we hear.
Connections for the piezoelectric buzzer are as follows

1. Place the piezo buzzer into the breadboard, so that the two leads are on two separate rows.
2. Using jumper wires, connect the positive lead to Arduino digital pin 8. The case of the buzzer
may have a positive sign (+) on it to indicate the positive lead (if not, then the red wire usually
indicates the positive lead).
3. Connect the other lead to the 100 ohm resistor, and then to ground (here resistor is used to
control the amount of current flow).

13
Microprocessors and Microcontrollers
Fig. buzzer circuit diagram

The code for the connection

//A sketch to demonstrate the tone() function

//Specify digital pin on the Arduino that the positive lead of piezo buzzer is attached.

int piezoPin = 3;

14
Microprocessors and Microcontrollers
void setup() {

}//close setup void

loop() {

/*Tone needs 2 arguments, but can take three

1) Pin#

2) Frequency - this is in hertz (cycles per second) which determines the pitch of the noise made

3) Duration - how long the tone plays

*/ tone(3, 1000,

50);

//tone(3, 1000, 50);

//delay(1000);

Here the buzzer is connected to third pin and it gives the beep sound at 1000hz frequency and at every
50 ms when the person is nearing less than 130cms.or else there will no sound if the person is far
away.

15
Microprocessors and Microcontrollers
A 4 Arduino Program & Circuit:

Figure 1 Circuit

Figure 2 Program Flow Chart

16
Microprocessors and Microcontrollers
17
Microprocessors and Microcontrollers
Figure 3 Arduino Code
A 5 Simulation:

Figure 4 Simulation Image - Notice the buzzer in the last image

18
Microprocessors and Microcontrollers
Simulate Here - https://www.tinkercad.com/things/6qeXa5h7e2f

A 6 Coursera Certificates: The certificates are attached in the last page. I have merged the original
certificate document so it can be a little out of frame with the rest document.

Bibliography
____________________________________________________________________________________

1. Tinker Cad Arduino Simulator, https://tinkercad.com/circuits


2. Arduino Website, https://www.arduino.cc/ 3. Adafruit NeoPixel,
https://learn.adafruit.com/adafruit-neopixel-uberguide

19
Microprocessors and Microcontrollers

You might also like