Professional Documents
Culture Documents
Untitled
Untitled
Experiment Title 3
Objectives 3
Equipment List 3
Circuit Diagram 3
Code/Program 4
Hardware Output Results 8
Simulation Output Results 10
Discussion 13
References 13
Page 2 of 13
Experiment Title: Familiarization with a microcontroller, the study of blink test using and
implementation of a traffic control system using microcontroller and Proteus Simulation platform.
Objectives:
The objectives of this experiment are to-
1. Familiarize with the Arduino microcontroller
2. Implement a simple circuit to make an LED light to blink using the delay function
3. Implement a simple traffic control system
Equipment List:
1. Arduino board
2. Breadboard
3. LED lights (red, yellow, green)
4. Jumper wires
Circuit Diagram:
The Arduino platform is made up of the following components.
Page 3 of 13
Fig. 2 Hardware circuit diagram for the traffic light
Code/Program:
(i) Codes for Fig. 1
void setup() {
// put your setup code here, to run once:
pinMode(5,OUTPUT);
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(5,HIGH);
delay(1000);
digitalWrite(5,LOW);
delay(1000);
Page 4 of 13
Explanation:
Line 1: void setup()
This line is to setup the Arduino devices.
Line 2: pinMode(5,OUTPUT);
This line is to setup the pin 5 of the Arduino device as output.
Line 4: digitalWrite(5,HIGH);
In this line a function, digitalWrite where parameters are 5 and HIGH. 5 indicates pin 5 and HIGH
indicates the output of the pin as high.
Line 5: delay(1000);
In this line a function, delay is called. Where parameter is 1000. Here 1000 means 1000ms. During
1000ms there will be no changes in the output of the Arduino device.
Line 6: digitalWrite(5,LOW);
In this line a function, digitalWrite where parameters are 5 and LOW. 5 indicates pin 5 and LOW
indicates the output of the pin as low.
Line 7: delay(1000);
Same as line 5.
int redOn=3000;
int yellowBlink=1000;
int greenOn=5000;
void setup() {
pinMode(redPin, OUTPUT);
pinMode(yellowPin, OUTPUT);
pinMode(greenPin, OUTPUT);
}
void loop() {
digitalWrite(greenPin, HIGH);
delay(greenOn);
digitalWrite(greenPin, LOW);
for(int i=0; i<=3; i++)
{
Page 5 of 13
digitalWrite(yellowPin, HIGH);
delay(yellowBlink);
digitalWrite(yellowPin, LOW);
delay(yellowBlink);
}
digitalWrite(redPin, HIGH);
delay(redOn);
digitalWrite(redPin, LOW);
Explanation:
Line 1: #define redPin 3
In this line redPin is defined as pin 3 of the Arduino device.
Page 6 of 13
Line 12: digitalWrite(greenPin, HIGH);
In this line a function, digitalWrite where parameters are greenPin (pin 11) and HIGH. 11 indicates
pin 3 and HIGH indicates the output of the pin as high.
Page 7 of 13
Hardware Output Results:
Blink Light: In this figure the light is turned on and off repeatedly after 1000ms.
Page 8 of 13
Traffic light: In this figure the green is turned on for 5000ms. Then the yellow light is turned on for
1000ms and turned off for 1000ms for 4 times repeatedly. Then the red light is turned on for 3000ms. This
whole process will be repeated forever until change.
Page 9 of 13
Fig. 2.3: Traffic Light (Red light is on)
Page 10 of 13
Fig. 1.2: Blink Light (Light is on)
Traffic Light: For this simulation, 1 Arduino Uno R3, 3 resistor, 1 red led light, 1 yellow led light, 1
green led light and a breadboard was used. Pin 11 of the Arduino devices, a resistor, the green led, and
ground was connected in series. Like this Pin 6 was in series with yellow led and Pin 3 was in series with
red led. Then the code of traffic light was inputted into the Arduino device.
Page 11 of 13
Fig. 2.2: Traffic Light (Yellow light is on)
Page 12 of 13
Discussion:
In this lab experiment we learned how to use Arduino device. For that we had to use Arduino
software.
In this experiment we simulated two simple task, blink light and traffic lights.
For the blink light we had to setup a pin for output. Then in the loop function we had to call
function to turn the light on, off and delay.
For the traffic lights we had to setup 3 pins for the output. The pins are for green, yellow and red.
In the loop function first, we had to call function digitalWrite and delay to turn on the green light
for few times. Then we had to use same functions in a for loop to blink the yellow light for 4 times.
Finally using same functions, we turned on the red light for few times.
There was no issue in both hardware and software simulations.
References:
1) https://www.arduino.cc/.
2) https://www.coursera.org/learn/arduino/lecture/ei4ni/1-10-first-glance-at-a-program
3) Jeremy Blum; Exploring Arduino: Tools and Techniques for Engineering Wizardry
Page 13 of 13