Microprocessor Based Control Of Traffic Lights Computer Science Essay

Published: Last Edited:

This essay has been submitted by a student. This is not an example of the work written by our professional essay writers.

Microprocessor: A microprocessor is defined as the digital electronic component embedded with transistors on a single semiconductor integrated circuit. One or more than one microprocessors typically serve as a central processing unit in a computer system.

Microprocessor Components:

Basic Components:

The following are the basic components of the microprocessor:


A register is a storage element which is composed of an array of flip-flops. A 1-bit register can store 1 bit and a 32-bit register can hold 32 bits and so on. A register has two inputs:

Data input

Clock input.


A multiplexer is used as an input selector. A multiplexer has 1 output, a control input and other data inputs. If the control signal is "0", the 0th input is moved to the output. If the control signal is "7" then the 7th input is moved to the output.

A multiplexer with N control signal bits can support 2N inputs. For example, a multiplexer with 3 control signals can support 2pow(3) = 8 inputs.

A 4 input Multiplexer with 2 control signal wires

An 8 input Multiplexer with 3 control signal wires

A 16 input Multiplexer with 4 control wires

Program Counter

The Program Counter is a register structure which contains the address pointer value of the current instruction. For each cycle the value at the pointer is read into the instruction decoder and the program counter is updated to point to the next instruction.

Instruction Decoder:

The Instruction Decoder performs the function that it reads the next instruction in from memory and sends the component pieces of that instruction to the necessary destinations.

They are of two types:

RISC Instruction Decoder

The RISC instruction decoder is a simple device because RISC instruction words areof fixed length and the positions of the fields are fixed. We can decode an instruction, therefore, by simply separating the machine word into small parts using wire slices.

CISC Instruction Decoder

A CISC decoder is set up as a state machine. The machine reads the opcode field to determine the type of instruction and address of the other data values. The instruction word is read in part by part and decisions are made at each stage to determine how the remainder of the instruction word will be read.

Register File

A register file is a set of registers and a decoder. The register file requires an address and a data input.

The other components required are memory unit, ALU, FPU stands for floating point unit and control unit.


A microcontroller (also microcomputer, MCU or µC) is a small computer on a single integrated circuit consisting internally of a relatively simple CPU, clock, timers, I/O ports and memory. Program memory in the form of NOR flash or OTP ROM is also often included on chip, as well as a typically small amount of RAM. Microcontrollers are designed for small or dedicated applications.

Differences Between Microprocessor And Microcontroller:

Microprocessor = CPU

Microcontroller = CPU+ peripherals + memory

Peripherals = ports + clock + timers + ADC converters +LCD drivers

Memory = SRAM +EEPROM+ EPROM + flash

A microcontroller has a combination of all the above explained attributes whereas a microprocessor is only a CPU.

Examples of microprocessors are 8085 and 8086. The following is the pin diagram of 8086 microprocessor:

Examples of microcontrollers are 8254, 8279, 8255, 8259.

Microprocessor Based Control Of Traffic Lights


Now almost all the traffic light systems operate on a timing mechanism that changes the lights after a given time interval. An automated traffic light system senses the presence or absence of vehicles and reacts accordingly. An automated or intelligent traffic system detects traffic in many different ways. Current traffic systems react to motion to trigger the light changes. When the infrared object detector picks up the presence of a vehicle, a switch causes the lights to change. In order to accomplish this, algorithms are used to govern the actions of the traffic system. The traffic signal system consists of three important parts. The first part is the controller, which represents the brain of the traffic system. It consists of a computer that controls the selection and timing of traffic movements in accordance to the varying demands of traffic signal as registered to the controller unit by sensors. The second part is the signal visualization or in simple words is signal face. Signal faces are part of a signal head provided for controlling traffic in a single direction and consist of one or more signal sections. These usually comprise of solid red, yellow and green lights. The third part is the detector or sensor. The sensor or detector is a device to indicate the presence of vehicles. One of the technologies, which are used today, consists of wire loops placed in the pavement at intersections. They are activated by the change of electrical inductance caused by a vehicle passing over or standing over the wire loop.

Experimental Arrangement:

In order to implement the Intelligent Traffic Signal Simulator, one needs to setup and assemble the hardware components and write a program to control the intelligent traffic signal simulator. The layout of the Intelligent Traffic Signal Simulator is displayed in Figure 1. The blocks, which are labeled N1, N2, N3, E1, E2, E3, S1 and W1 are the infrared object detectors.

Hardware components:

The traffic light system consists of four important components: the controller which is taken as brain to the system, the sensors which detect the presence of vehicles, the light emitting diodes (LED) which act as the actuator and the countdown timers which is displayed in Lab VIEW. BASIC STAMP 2 (BS2) is used as the microcontroller of the traffic signal. The BS2, which needs to be plugged to the Board of Education (BoE), is

directly attached to the computer in order to program it. The wiring for the output and input signals is done from this board. Figure 2 shows the Board of Education to which a 9V DC power is supplied. There is also a DB9 connector, that is connected to the COM port of computer using RS-232 serial cable, for BS2 programming and serial communication during run-time. Next to the BS2, there is a breadboard. The breadboard has many strips of copper, which run underneath the board in a horizontal fashion. These strips connect the sockets to each other. As for the infrared object detector, SHARP GP2D15 is used. The sensor task is to detect the presence of vehicles. It is functioning continuously by giving a logic 0 when there are no vehicles and logic 1 when there are vehicles present. Therefore, they can detect the length of the queue depending on where they are placed. Each detector has a JST connector housing slot and three crimped wires to use in the JST connector. The connectors are plugged into the appropriate housing slot and into the detector. The light emitting diodes are used in order to show the traffic light changing according to the program. The LED light will change according to output by the microcontroller. In each lane, there are three LEDs according to traffic lights colors which consist of red, yellow and green. Moreover, two inverters were used in order to connect the output of green and red LEDs

together. Therefore, when the green LED is ON then the red LED will be OFF and vice-versa. Figure 3 shows the connection of the input and output ports to sensors and LEDs. The BS2 microcontroller has 16 Input and Output ports. The ports were divided into 8 input and 8 output ports. The output ports, which are from P0 to P7, give either logic 0 or 1 to the LEDs. The input ports, which are from P8 to P15, receive input signal from the sensors.

Software simulation:

After the hardware had been setup, a program written in the BASIC programming

language in the BASIC STAMP editor is downloaded into the microcontroller. The simulation of the algorithm of the traffic signal system was done using MATLAB software. The countdown timer interfacing according to the traffic system using Lab VIEW software is created using the BNC Adapter and the Data Acquisition Card (DAQ) device. The Lab VIEW programming is done in the diagram using graphical source code. In the block diagram the program runs from left to right. If the green

Fig. 1: Intelligent traffic signal simulator layout

Fig. 2: Board of Education

Fig. 3: Connection of the input and output ports to sensors and LEDs

Fig. 4: Traffic signal sequence

light in the traffic model does not illuminate, the system goes into default since there is no input into the system. The signal from the sensor is acquired through the DAQ, which is connected, to the computer.

Using 8085 to Design:

The hardware of the system consists of two parts. The first part is Microprocessor based system with 8085. Microprocessor as CPU and the peripheral devices like EPROM, RAM, Keyboard & Display Controller 8279, Programmable as Peripheral Interface 8255, 26 pin parallel port connector, 21 keys Hexa key pad and six number of seven segment LED's.

The second part is the traffic light controller interface board, which consist of 36 LED's in which 20 LED's are used for vehicle traffic and they are connected to 20 port lines of 8255 through Buffer. Remaining LED's are used for pedestrian traffic. The traffic light interface board is connected to Main board using 26 core flat cables to 26-pin Port connector. The LED's can be switched ON/OFF in the specified sequence by the Microprocessor.






26 pin port connector

26 pin port connector




26 pin

FRC cable


System Bus







Anode driver



Cathode driver


Fig 1: Block diagram of Traffic Light Controller

Result and Conclusion:

The traffic signal operation will start by the traffic lights illuminating in red for 1 second in all directions. Then the traffic signals will start illuminating in the clockwise direction of the magnet compass. This means that it will start operating in the North lane, then East lane, then South lane, then West lane and goes back to North lane.