MC RPT
MC RPT
On
3-ECE-2
Guided By
Mr.D.Sudhakar
Assistant Professor
Department of ECE
1
MAHATMA GANDHI INSTITUTE
OF TECHNOLOGY
(Autonomous)
(Kokapet Village, Gandipet, Hyderabad, Telangana –
500 075
CERTIFICAT Date:
E
This is to certified that project entitledTraffic Light Control System using 8051
Microcontroller has been submitted to Department of Electronics and Communication
Engineering, Mahatma Gandhi Institute of Technical for the partial fulfillment of the
requirement of B.Tech. 5-Sem Micro Controllers course.
Signature Signature
Dr. S P Singh
Mr.D.Sudhakar
Project guide Professor & Head of ECE
2
INDEX
1.Abstract 4
2.Introduction 5
3.Code 6
4.Code Explanation 7-8
5.Circuit Diagram 9
6.Output 9
7.Application 10
8.Result 11
ABSTRACT
This Traffic Light Control System simulates the functioning of a traffic light at an intersection, utilizing
the 8051 microcontroller and Assembly language for embedded programming. The system is designed to
control the switching between green, yellow, and red lights based on fixed time intervals, without any
real-time traffic management or sensor inputs.
The system operates by cycling through three primary states of a traffic light: Green, Yellow, and Red.
Each light has a fixed duration, implemented using delay loops to create the appropriate timing for each
state. The green light stays on for a set duration, followed by the yellow light for a brief period, and then
the red light stays on for a longer duration, allowing the traffic to stop. The cycle is repeated indefinitely.
Microcontroller Control (8051): The 8051 microcontroller handles the logic for controlling the states
of the traffic lights and ensuring they transition properly according to the pre-programmed delays.
Fixed Timings: The system operates on fixed time intervals for each light state, with no dynamic
adjustment based on traffic conditions. The green light stays on for 10 iterations of a delay loop, the
yellow light for 5 iterations, and the red light for 15 iterations. These durations are fixed in the code.
Delay Subroutine: The delay is generated using nested loops, creating an approximate time delay
between each state transition. The delay subroutine executes multiple loops to achieve the required
timing for each light.
LED Control: The traffic lights are represented using LEDs connected to specific pins on Port 1 of the
8051 microcontroller. Green, yellow, and red lights are represented by the LEDs on P1.0, P1.1, and P1.2,
respectively. The status of the LEDs is controlled by setting or clearing these pins.
In this system, no real-time adjustments are made based on the number of vehicles or other traffic
conditions. The system operates on a fixed, repetitive cycle, offering a simple and cost-effective solution
for simulating traffic light operations. This can be used as a basic prototype for educational purposes or
as the foundation for more complex traffic management systems that may incorporate sensors or
adaptive algorithms in the future.
INTRODUCTION
Traffic congestion is a significant challenge in modern urban areas, leading to delays, fuel waste, and
increased risk of accidents. Efficient management of traffic flow is critical to improving road safety and
reducing the time spent waiting at intersections. One of the most fundamental solutions for managing
traffic at intersections is the use of traffic lights. These systems control the flow of vehicles and
pedestrians, ensuring safe and organized movement.
The Traffic Light Control System described in this project is designed to simulate the functioning of a
traffic light using the 8051 microcontroller. The 8051 microcontroller, a widely used and cost-effective
8-bit processor, is used to automate the operation of traffic lights at an intersection. This system operates
on fixed timing intervals for each of the three light states—green, yellow, and red—and simulates the
standard traffic light cycle.
In this system, the green light indicates that vehicles can pass, the yellow light serves as a warning that
the light is about to change, and the red light instructs vehicles to stop. The microcontroller controls the
switching of these lights in a cyclic pattern, with specific delays programmed for each state. The timing
for each light is predetermined and does not adjust based on traffic density or real-time vehicle detection.
The traffic light system is implemented with the help of assembly language programming, leveraging the
simplicity and efficiency of the 8051 microcontroller. This project serves as a fundamental example of
how embedded systems can be used to automate simple traffic control applications. Although the system
operates based on fixed timing, it lays the foundation for further developments, such as adaptive traffic
control based on real-time conditions or integration with vehicle sensors for dynamic traffic light
adjustments.
This system is beneficial for educational purposes, demonstrating how embedded programming and
microcontrollers can be used for real-world applications like traffic light control. It also highlights the
potential for using microcontroller-based systems to automate and improve everyday infrastructure
systems in cities and towns.
CODE
START:
; Green Light Simulation
MOV R0, #10 ; Set delay counter for Green Light (10 cycles)
Green_Light:
; Simulate Green Light - Turn ON Green LED (e.g., P1.0)
SETB P1.0 ; Set P1.0 High (Green LED ON)
CLR P1.1 ; Ensure Yellow LED is OFF
CLR P1.2 ; Ensure Red LED is OFF
DJNZ R0, Green_Light ; Decrement R0 and loop until zero
This code is designed to simulate the operation of a basic traffic light control system using the 8051
microcontroller and assembly language. The system controls three LEDs representing the Green,
Yellow, and Red traffic lights, cycling through each color with fixed timing delays. The 8051
microcontroller, being an 8-bit processor, is responsible for controlling the states of the LEDs based
on predetermined delays, and it operates in a simple, non-adaptive manner (i.e., there are no sensors
or real-time vehicle detection in this simulation).
Code Breakdown:
2.Port Initialization:
CLR P1.0, CLR P1.1, CLR P1.2 ensures that all traffic lights (Green, Yellow, Red) are initially
turned OFF by clearing the respective bits (pins) on Port 1.
P1.0: Controls the Green light.
P1.1: Controls the Yellow light.
P1.2: Controls the Red light.
KEY CONCEPTS
Port Control (P1.0, P1.1, P1.2):Port 1 is used for controlling the traffic lights. Setting a bit to 1 turns
on the corresponding LED (green, yellow, or red), while clearing a bit (CLR) turns it off.
Delay Mechanism:The delay subroutine uses nested loops to introduce a fixed delay, which allows
the LEDs to remain on for specific durations, controlling the timing of each light
Assembly Language Programming:This code uses basic assembly instructions such as SETB, CLR,
MOV, DJNZ, and CALL to control the microcontroller and LEDs, demonstrating how low-level
programming can be used to achieve time-based control of hardware components.
Fixed Timing:The timings for the green, yellow, and red lights are hard-coded into the program (10
iterations for green, 5 for yellow, and 15 for red). The system does not adjust based on traffic
conditions or external inputs, making it a simple, non-adaptive traffic light simulation.
CIRCUIT DIAGRAM
OUTPUT
GREEN
YELLOW
RED
APPLICATIONS
The Traffic Light Control System using the 8051 microcontroller is a fundamental application of
embedded systems and provides the basic functionality required to control traffic lights at
intersections. The system operates on the principle of managing the state of three traffic lights—
green, yellow, and red—using fixed delays between each state to simulate the common cycle of traffic
lights.
The 8051 microcontroller, being a widely used and cost-effective 8-bit processor, controls the timing
of the light changes and ensures that they transition in a predefined, cyclic order. The system's
primary components include the microcontroller, LEDs representing the traffic lights, and a delay
subroutine that introduces the necessary time gaps between light changes. This system provides a
basic model for traffic light control, simulating how traffic signals are typically managed in real-life
intersections.
Although the system is designed with fixed timing intervals (green for 10 seconds, yellow for 5
seconds, and red for 15 seconds), it can be modified and extended in a variety of ways to suit different
needs. For example, the fixed timing can be adjusted to better suit real-world traffic patterns, or
additional sensors can be incorporated to allow for adaptive control based on traffic conditions. While
this system does not include such dynamic features, it provides a simple and effective foundation for
more complex traffic management solutions.
In terms of future development, the basic traffic light control system can serve as a prototype for
more advanced systems. For example, integrating sensors that detect the presence of vehicles can
enable dynamic light timing, allowing the traffic lights to adjust in real-time based on traffic volume.
Furthermore, the system can be integrated with centralized control systems, enabling synchronization
of traffic lights across multiple intersections in a city, reducing congestion, and improving overall
traffic management.
In conclusion, the Traffic Light Control System using the 8051 microcontroller provides a
straightforward and effective solution for controlling traffic lights at intersections. While it operates
on a simple fixed-timing basis, its flexibility allows for future enhancements, including adaptive
control, real-time traffic monitoring, and integration into larger, smart traffic management networks.
RESULT
Visual Output:
On a physical setup with LEDs connected to P1.0, P1.1, and P1.2:
Initially, all LEDs will be OFF.
During the Green light phase, the Green LED will be ON, while the Yellow and Red LEDs will remain
OFF.
When transitioning to the Yellow light phase, the Yellow LED will turn ON, and both the Green and
Red LEDs will be OFF.
During the Red light phase, the Red LED will turn ON, and the Green and Yellow LEDs will be OFF.
After the Red light, the entire cycle will repeat.
Practical Observation:
If you were to observe the system in real-time, you would see the traffic lights cycle through the
following states:
Green Light ON (Green LED ON) for ~10 seconds.
Yellow Light ON (Yellow LED ON) for ~5 seconds.
Red Light ON (Red LED ON) for ~15 seconds.
This pattern will repeat continuously, controlling the traffic light sequence in a predictable manner.
Output Summary:
Green Light (P1.0): ON for 10 cycles, OFF for the remainder.
Yellow Light (P1.1): ON for 5 cycles, OFF for the remainder.
Red Light (P1.2): ON for 15 cycles, OFF for the remainder.
This simple timing-controlled system ensures that the traffic lights change in a fixed sequence, with
each light having a specific duration before the next transition.