You are on page 1of 7

SCHOOL OF COMPUTING AND ENGINEERING SCIENCES (CSES)

BACHELOR OF SCIENCE IN ELECTRICAL AND ELECTRONICS


ENGINEERING (BSEEE)

PROJECT 1: ONE WAY TRAFFIC LIGHT

BY
Group 4:
TREVOR AYIMBA
BAHATI MELCHIOR
DEBORAH AJAO

Lecturer: Prof JACKSON MWANGI M.

1. INTRODUCTION
This first Project is a simulation of simple one-way traffic light using a simple
electric circuit.
Electric circuit, path for transmitting electric current. An electric circuit
includes a device that gives energy to the charged particles constituting the
current, such as a battery or a generator; devices that use current, such
as lamps, electric motors, or computers; and the connecting wires or
transmission lines. Two of the basic laws that mathematically describe the
performance of electric circuits are Ohm’s law and Kirchhoff’s rules.
A traffic Light is a set of automatically operated colored lights, typically red,
amber, and green, for controlling traffic at road junctions, pedestrian crossings,
and roundabouts.
Traffic lights follow a universal colour code which alternates the right of
way accorded to users with a sequence of illuminating lamps or LEDs of three
standard colours:
- Green light
Allows traffic to proceed in the direction denoted, if it is safe to do so and
there is room on the other side of the intersection.
- Red light
Prohibits any traffic from proceeding. A flashing red indication requires
traffic to stop and then proceed when safe (equivalent to a stop sign).
- Amber light (also known as 'orange light' or 'yellow light')
Warns that the signal is about to change to red, with some jurisdictions
requiring drivers to stop if it is safe to do so, and others allowing drivers
to go through the intersection if safe to do so. In some European countries
(such as the UK), red and amber is displayed together, indicating that the
signal is about to change to green

2. APPARATUS
For our experiment we use several materials such as:
1. A breadboard

2. An Arduino Uno

3. Some jumper wires

4. Some LEDs
5. Some resistors

6. A laptop as a power supply,

7. A pushbutton
3. METHODOLOGY
We used the logic of traffic light state before in our introduction to implement a
simple circuit which will respond to a simple C++ program from Arduino to run
as a true traffic light.
We therefore begin by doing a simulation Using Thinker cad to be sure of what
we are doing.
A picture of the simulation is attached to our Analytic Folder and our videos
folder will show you the whole Circuit Design and explanations.
We also used C++ Language in the Arduino IDE to upload a code which will
lead the work of our LEDs and Pushbutton.
The explanation of the code will be provided in the lines below and the Circuit
setup will be seen through the videos.

4. CODE EXPLANATION

This is a copy of the code we used in C++ for our project


//declare the LEDs

int redLed=11;
int orangeLed=10;
int greenLed=9;
int greenped=8;
int redped=7;

//declare the pushbutton pin

int pushbutton=2;

int readpushbutton=0;
void setup()
{
pinMode(redped,OUTPUT);
pinMode(greenped,OUTPUT);
pinMode(redLed, OUTPUT);
pinMode(orangeLed, OUTPUT);
pinMode(greenLed, OUTPUT);
pinMode(pushbutton, INPUT);

digitalWrite(redLed, LOW);
digitalWrite(orangeLed, LOW);
digitalWrite(greenLed, LOW);
digitalWrite(greenped,LOW);
digitalWrite(redped,LOW);

Serial.begin(9600);
}
void loop()
{

int readpushbutton = digitalRead(pushbutton);


if ( readpushbutton==0){

digitalWrite(greenLed, HIGH);
digitalWrite(orangeLed, LOW);
digitalWrite(redLed, LOW);
digitalWrite(redped, HIGH);
digitalWrite(greenped, LOW);

}
else if (readpushbutton==1){
digitalWrite(greenLed, LOW);
digitalWrite(orangeLed, HIGH);
digitalWrite(redLed, LOW);
Serial.println("PEDESTRIAN WAITING");
delay(5000);

digitalWrite(greenLed, LOW);
digitalWrite(orangeLed, LOW);
digitalWrite(redLed, HIGH);
digitalWrite(greenped,HIGH);
digitalWrite(redped, LOW);
Serial.println("PEDESTRIAN CROSSING");
delay(20000);
}

● Circuit Explanation
To explain it we shall just see that we have one input which is the Pushbutton
connected to the pin 2 of the Arduino and 5 outputs which are all LEDs, and
which are connected to the ground of the motherboard through resistors so that
the 5V current coming from the laptop through the Arduino can’t damage them.
when we upload the code to the Arduino which is connected to the laptop
(Power supply) The current begins flowing in our circuit.
● Code Explanation
- Initial set up
As it can be seen by the void loop of our circuit at the beginning when we
launch the code the side of motorist which is green allow them to pass while the
side of pedestrians is red so they can pass,
- Request for a pass and explanations
when a pedestrian want to request for a pass, he want to pass, he has just to
press the button and then the immediately the side of motorist will turn to
yellow to tell them to be ready to stop it will last for a time then, the side of
motorist will become red and the one of pedestrians will become green so
pedestrian are allowed now to pass, and it will last also for a great amount of
seconds so all the pedestrian across the road can cross and it will come back to
its initial setup.
Since we code it in a loop this process will run as a loop for as much time as a
pedestrian can request for a pass.

5. CONCLUSION
We can easily understand from the lines above that our Circuit is working like a
Traffic Light circuit and it has the same principle.
We can therefore conclude that this a simple way of simulating big Stuffs of life
Using Simple Circuit.
More Interesting and Big project will be done as we are progressing.
THANK YOU

You might also like