Department of Electrical and Electronic Engineering
Dhaka University of Engineering and Technology, Gazipur
Course No: EEE-3004, Title: Electrical & Electronic Design
Experiment No: 03
Design and Simulation of a microcontroller-
proteus ISIS.
ased traffic light control system using
Objectives:
To Team about the functionality ané modules of'a micencontroller,
To familiarize with the basic operation of the Arduino Uno board, and Integrated
Development Environment (IDE).
‘© To design and simulate a microcontroller-based electronic circuit.
Introduction:
A microcontroller is a compact integrated c reuit (IC) that is specifically designed to control a
particular function within an embedded sys‘em. It typically contains a central processing unit
(CPU), memory storage, and input/output devices integrated into a single circuit.
A microcontroller is like @ computer. All computers have several things in common:
Central processing unit (CPU) - The CPU is the "brain" of the microcontroller that performs
all the necessary computations and logie operations.
Memory - The microcontroller has both volatile and non-volatile memory. Volatile memory,
such as Random Access Memory (RAM), is used for storing data that can be accessed and
changed quickly. Non-volatile memory, such as Read-Only Memory (ROM), is used for storing
data that should not be changed, such as the microcontrolier's program code.
Input/output (1/0) peripherals - The /O peripherals are used for communicating with the
external world. They include analog-to-digital converters (ADCs) for converting analog signals
to digital data, digital-to-analog converters (DACs) for converting digital signals to analog
data, and other 1/0 interfaces for connecting to various external devices, such as sensors and
actuators,
Microcontrollers are a type of "special purpose computer” that differs in several ways from
traditional personal computers ovr
1. Microcontrollers are often embedded in other devices to control their features or
actions. They are commonly found in products such as washing machines, thermostats,
and automotive systems
Microcontrollers typically run one specific program because they are dedicated to a
single task, which is stored in read-only memory (ROM) and generally does not
change.
SANJID-E-ELAHI
a of EEE, DUET [Pave3. Microcontrollers are often more efficient and have lower power requirements than
personal computers. For example, a desktop computer might consume 50 watts of
electricity, while a battery-operated microcontroller might consume only 50 milliwatts.
= om ©
Microcontroller
Figure 1: Parts of a microcontroller. (Source: Max Embedded)
‘There are many different brands of microcontrollers available on the market, each with its
own unique features and capabilities, Some of the most common microcontroller brands
include:
Atmel (now a part of Microchip Technology)
Texas Instruments (T!)
SYMicroelectronies (ST)
Renesas Electronies
NXP Semiconductors
Microchip Technology (which acquired Atmel)
Cypress Semiconductor
Infineon Technologies
Silicon Laboratories
Analog Devices (ADI
Each of these brands offers a variety of microcontrollers with different specifications, so the
choice of brand and microcontroller will depend on the specific requirements of the project or
application,
SANJID-E-ELAHI
a of EEE, DUET 21PaveArduino:
Arduino is a popular open-source platform for building electronics projects. It consists of both
hardware and software components that are designed to be easy to use and accessible to
beginners and experts alike.
The Arduino hardware consists of a microcontroller, such as the Atmel AVR microcontroller,
and a variety of input and output componexts, including digital and analog pins, USB ports,
and power supply inputs. The software component includes the Arduino Integrated
Development Environment (IDE), which provides a simple programming environment for
writing and uploading code to the microcontroller. Overall, Arduino is a versatile and user-
friendly platform for anyone interested in building electronics projects, from hobbyists to
professionals
There are many different Arduino board variants available, each with its own unique set of
features and specifications. Here are some ef the most popular Arduino board variants:
‘* Arduino Uno: The Uno is one of the most popular Arduino boards, featuring a 16 MHz
ATmega328P microcontroller, 14 digital inpuvoutput pine, 6 analog inputs, a USB
connection, and a power jack.
‘* Arduino Nano: The Nano is a compact version of the Uno, featuring a 16 MHz
ATmega328P microcontroller, 14 digital input/output pins, 8 analog inputs, a USB
connection, and a power jack
‘* Arduino Mega: The Mega is a larger Arduino board, featuring a 16 MHz ATmega2560
microcontroller, 54 digital input/output pins, 16 analog inputs, and multiple serial
communication ports.
‘© Arduino Due: The Due is a powerful Arduino board, featuring a 84 MHz SAM3X8E
microcontroller, 54 digital input/output pins, 12 analog inputs, and multiple serial
communication ports.
+ Arduino Leonardo: The Leonardo features a 16 MHz ATimega32u4 microcontroller, 20,
digital input/output pins, 12 analog inputs, and a built-in USB connection
‘+ Arduino Pro Mini: The Pro Mini is @ small Arduino board, featuring a 16 MHz
ATmega328P microcontroller, 14 digital input/output pins, 6 analog inputs, and a
power jack
These are just a few examples of the many different Arduino board variants available. Each
buaid is designed for a specific use vase, s0 its important ty chuvse the right buaid for your
project based == on——your—specific_-—needs.»—and-—_requirements.
Arduino Uno:
The Arduino Uno is a popular microcontroller board based on the ATmega328P
microcontroller. It features 14 digital input/output pins, 6 analog inputs, a 16 MHz quartz
crystal, a USB connection for programming and power, a power jack, and a reset button, The
Uno is great choice for beginners and experienced users alike, as it is easy to use and has a
Iarge commnnity of users and developers crating and sharing projects and lihraries. The Uno
can be used to create a wide range of projects, from simple LED blinkers to complex robots
and IoT devices. It is also compatible wich a wide range of sensors, actuators, and other
components, making it a versatile platform “or prototyping and experimentation,
SANJID-E-ELAHI @deparun
a of EEE, DUET alPoveSerial Out (TX)
Serial in (RX)
Reset Button
Sonal Programmer
‘Atmega328.
Microcontroller
Analog In
Pins (0-5)
void setup() {
// pat your setup code here, to run once:
void Loop() {
// put your main code he:
, to run repeatedly:
}
Figure 3: Arduino Integrated Development Environment (IDE)
SANJID-E-ELAHI alPeveArduino Uno Board Specifications:
Microcontroller ATmega328
OperatingVoltare sv
Input Voltage (recommended) 71
Input Voltage (limits) 620v
Digital VO Pins 14 (of which 6 provide PWM output)
‘Analog Input Pins ‘
DC Current per VO Pin 40mA
DC Current for 3.3V Pin 50 mA
Fh Memory 32 KB (ATmeq28 of which 05 KB used
SRAM 2 KB (ATmega328)
EEPROM 1 KB (ATmega328)
Clock Speed 16 Mie
Length 68.6 mm
Width 534mm
Weight Be
Component Explanations
Analog input pins - pins (A0-AS) that take-in analog values to be converted to be
represented with a number range 0-1023 through an Analog to Digital Converter
(ade)
ATmega328 chip - 8-bit microcontioller that processes the sketch you programmed.
Built-in LED-an on board LED to pin 13,
Crystal Oseillator- clock that has a frequency of l6MHz,
DC Jack - where the power source (AC-to-DC adapter or battery) should be
connected, It limited to mput values between 6-20V but recommended to be around
TD.
Digital /O pins - input and output pins (0-13) of which 6 of them (3, 5, 6, 9, 10 and
11) also provide PWM (Pulse Width Modulated) output by using the analogWrite()
function. Pins (0 (RX) and 1 (TX) cre also used to transmit and receive serial data,
ICSP Header - pins for "In-Circuit Serial Programming” which is another method of,
programming,
ON indicator - LED that lights up when the board is connected to a power source.
Power Pins - pins that can be used to supply a circuit with values VIN (voltage from
DC Jack), 3.3V and SV.
Memory Types in Arduino Uno
SANJID-E-ELAHI
a of EEE, DUET SlPexe‘Memory types for smart card micocontrollers
volatile memory non-wlatile memory
‘raw ROM
PROM
EPROM
EEPROM
Flach EEPROM
FRAM
The Arduino Uno has 32KB of flash memory for storing the user's program, 2KB of SRAM
for storing variahles, and 1K Raf FEPROM for ctoring data that needs tale retained even when
power is removed. The flash memory is non-volatile, which means that it retains its contents
even when power is removed, The SRAM and EEPROM are volatile, which means that they
require power to retain their contents. The amount of memory available on the Uno is generally
sufficient for most hobbyist projects, but formore complex projects, other Arduino boards with
more memory may be necessary.
There are several advantages to using microcontrollers, such as Arduino, in electronics
pivjects.
‘+ Low Cost: Microcontrollers are often less expensive than other computer systems, such
as desktop computers, making them accessible to hobbyists and small businesses.
‘* Small Size: Microcontrollers are designed to be small and compact, which makes them
‘deal for use in embedded systems where space is limited.
‘* Low Power Consumption: Microcontrollers are designed to consume minimal power,
‘making them ideal for use in battery-powered applications.
‘+ Ease of Use: Microcontrollers, particularly Arduino, are designed to be user-friendly
and casy to program, making them accessible to people with little to no programming
experience,
‘+ Versatility: Microcontrollers are casable of performing a wide range of tasks, from
simple to complex, making them useful in a variety of applications.
© Availability of Open-Source Libraries: The open-source nature of microcontroller
platforms like Arduino has led to the development of many libraries, which ean be used
to quickly and easily add functionality to a project.
Overall, microcontrollers like Arduino offer a combination of low cost, low power
consumption, versatility, and ease of use, making them a popular choice for a wide range of
electronics projects.
SANJID-E-ELAHI
a of EEE, DUET 6lPeveMicrocontroller-based traffic light control system
A traffic light system isan electronic device that uses red, yellow, and green colored indications
to assign right-of-way to drivers, riders, or pedestrians at intersections, crossings, or street
‘crossings, Itis commonly known as a traffic signal, stop light, or stop-and-go light. Its purpose
is to indicate when itis safe to proceed, based on a universal color code and sequence that is
also designed to accommodate those who are colorblind. While improved traffic flow ean be
‘beneficial for the environment and economy, it may also lead to an inerease in demand, which
‘could potentially result in traffic congestion.
4 WAY TRAFFIC LIGHT CONTROL SYSTEM DESIGN:
We have designed 4-way traffic lights in this way:
First the Lane 1 will turn on (green) for 7 seconds while the rest arc off. Then Lane 1 and Lane.
3 is steady state (yellow) for 3 second.
After that Lane 3 will turn on (green) for 7 second. Then Lane 3 and Lane 4 is steady state
(yellow) for 3 second.
Similar way after this Lane 4 and then Lane 2 will turn ON in this manner.
Required Components
1. Arduino Uno
2. Traffic Lights module
3. Terminals
Procedure:
Place the component in your worksheet as lustrated in the figure below:
Figure 4: Placement of components
SANJID-E-ELAHI @Deper
Wl uf EEE, DUET 71PageConnect 13, 12 and 11 digital pins of Arduino to red, yellow and green of traffic light 1
respectively.
© Connect 10, 9 and 8 digital pins of Arduino to red, yellow and green of traffic light 2
respectively
© Connect 7, 6 and 5 digital
respectively.
© Connect 4,3 and 2 digital pins of Aréuino to red, yellow and green of traffic light 4
respectively.
«After this write down the following programing code in Arduino IDE
of Arduino to red, yellow and green of traffic light 3
Arduino Program
int Lanet{] = {13,12,11}; // Lane 1 Red, Yellow and Green
{nt Lane2{(] = {10,9,8);// Lane 2 Red, Yellow and Green
Lane3|] = (7,6,5}:// Lane 3 Red, Yellow and Green
Int Lane4{] = {4,3,233// Lane 4 Red, Yellow and Green
void setup()
c
for (int 1=0;1< 3; i++)
(
pinMode(Lane'{i], OUTPUT);
pinMode(Lane2{i], OUTPUT);
pinMode(Lane3{i]. OUTPUT):
pinMode(Lane4{i], OUTPUT);
3
for (int i= 051 <3; i++)
(
igitalWrite(Lanetfi, LOW);
digitalWrite(Lane2{i], LOW);
igitalWrite(Lane3[i], LOW);
digitalWrite(Lanedfi], LOW);
3
oid loop)
{
digitalWrite(Lane1[2], HIGH);
SANJID-E-ELAHI
a of EEE, DUET alPovedigitalWrite(Lane3[0], HIGH);
digitalwrite(Lane4[0], HIGH);
digitalWrite(Lane2(0), HIGH);
delay(7000);
digitalwrite(Lane1[2], LOW);
digitalWrite(Lane3[0], LOW);
digitalwrite(Lane1[1], HIGH);
digitalWrite(Lane3[1], HIGH);
delay(3000);
igitatwite(Lanei[1], LOW);
digitalWrite(Lane3[1], LOW);
di
LWrite(Lanet[0}, HIGH);
digitalWeite(Lane2[2], HIGH):
delay(7000);
digitalwrite(Lane3[2], LOW);
digitalWrite(Lane4[0], LOW);
digitalWrite(Lane3[t], HIGH);
digitalwrite(Lane4[t], HIGH);
delay(3000);
digitalWrite(Lane3[t], LOW);
digitalWrite(Lane4[t], LOW);
digitalWrite(Lane3[0), HIGH);
digitalwrite(Lane4[2], HIGH);
delay(7000);
digitalWrite(Lane4[2], LOW);
digitatwite(Lanez[v}, LOW);
digitalWrite(Lane4[t], HIGH);
dightalWrite(Lane2[1], HIGH);
delay(3000);
digitalwrite(Lane4[t], LOW);
digitalWrite(Lanez[t1], LOW);
digitalwrite(Lane4[0}. HIGH):
digitalWrite(Lane2(2], HIGH);
delay(7000);
SANJID-E-ELAHI
a of EEE, DUET o1PevedigitalWrite(Lane1[0], LOW);
digitalrite(Lane2[2], LOW);
digitalWrite(Lane1[1], HIGH);
digitalWrite(Lane2(1], HIGH);
delay(3000);
italWrite(Lane2{1], LOW);
digitalWrite(Lanei[1], LOW);
I
‘* Compile the program, Then get the hex file from the code.( At the bottom of screen of,
the uploading program select the file path i
“C:\\Users\\S ANJID\\AppDatal\Local\\Temp\'arduino_build_394100/Traffic_light.in
oshex”)
‘Then double click “ARDUINO UNO R3". we will see Edit Component window after that
Browse it in Program File/ Put file path which selecting from the Arduino uploading window,
then click OK.
[aroun oR
(co © Ae
= ioe
(Oiwopemed