Embedded For You Magazine
Issue: March – April 2011
Traffic Light Controller
Traffic light controller is a traffic light simulator having a working GUI builds using national Instruments Labview. GUI software allows user to set the sequence order of each junction out of four and the on duration of each junction easily.Traffic Light controller has four junctions. Each having its corresponding seven segment display to show the stop timer. As stop time expires, Green light of the corresponding junction goes green.
Algorithm for calculating the order in which the Red lights have to glow is decided by the priority of the corresponding junction. See the attached source code of the traffic light algorithm implemented in Turbo C++.
Traffic Light Controller is a shield board to be connected with ESAT-ISP Development Tool (Manual & Specifications).
Traffic Light Controller - Do It Your Self!!
Writing the Microcontroller Code your self
1. Controlling the Seven Segments
BCD to 7-segment driver HEF4543 is used to display digits on seven segments. Control table of HEF4543 is given below.
There are Eight Seven Segments on Traffic Light controller board.
To display a number on a seven segment, it is first selected by pulling S1,S2,,S8 to 5 Volts(1).Numeric number to be displayed is selected by output of HEF4543 IC. See Table 1. for further details.
Code definitions:
//See Table 4 for Seven segment enable pins
A2/D3 | A0/D2 | A1/D1 | A3/D0 | Output |
L | L | L | L | 0 |
L | L | L | H | 1 |
L | L | H | L | 2 |
L | L | H | H | 3 |
L | H | L | L | 4 |
L | H | L | H | 5 |
L | H | H | L | 6 |
L | H | H | H | 7 |
H | L | L | L | 8 |
H | L | L | H | 9 |
Table 1 HEF4543 Details |
#define S2 PORTD.3//seven Segment 2
#define S3 PORTD.4//seven Segment 3
#define S4 PORTD.5//seven Segment 4
#define S5 PORTD.6//seven Segment 5
#define S6 PORTD.7//seven Segment 6
#define S7 PORTB.0//seven Segment 7
#define S8 PORTB.1//seven Segment 8
#define SEG_PORT PORTA
// See Table 1. A3/A2/A1/A0 are MCU pins and D3/D2/D1/D0 are HEF4543 pins.
unsigned char table[10]= {0x00,0x08,0x02,0x0A,0x01,0x09,0x03,0x0B,0x04,0x0C};
//to display a number on a given seven segment.
//To Enable Segment 1, corresponding enable pin is pulled up.
S1=1;
//Display a number on the Seven Segment 1 for Eg: to display 6
SEG_PORT= table[6];
Controlling Street Lights - Red/Orange/Green led lights
LS153 1-of-4 data selectors/multiplexers is used to select between Red - Orange/Green led lights for a traffic junction.
Red light of every traffic junction is tied to EN(1G or 2G) of corresponding LS153( See Table 2).Therefore when an EN pin of LS153 is disabled, corresponding Red light will glow, indicating a Red light .As long as EN pin is inactive orange and green light s will be disabled.
When EN pin is enabled Red light of the corresponding junction is automatically disabled.
Further Control pins A and B are used to indicate Yellow or Green signal according to your algorithm (see Table 3).
Pins A and B are common to all Junctions.
ENx | Result |
1 | Red ON |
0 | Red OFF |
Table 2 Enable/Disable LS153 |
#define EN1 PORTB.4
#define EN2 PORTB.5
B3/A | B2/B | Result |
0 | 0 | NA |
1 | 0 | NA |
0 | 1 | Orange |
1 | 1 | Green |
Table 3 Indicate Orange/Green light while LS153 is Active |
#define EN4 PORTC.4
#define A PORTB.3
#define B PORTB.2
//To Indicate Red Light on junction 1 and Green light on Junction 2
Seven Segment Details | |
Segment 1 | PORTD.2/ Arduino PIN1 |
Segment 2 | PORTD.3/ Arduino PIN2 |
Segment 3 | PORTD.4/ Arduino PIN3 |
Segment 4 | PORTD.5/ Arduino PIN4 |
Segment 5 | PORTD.6/ Arduino PIN5 |
Segment 6 | PORTD.7/ Arduino PIN6 |
Segment 7 | PORTB.0/ Arduino PIN7 |
Segment 8 | PORTB.1/ Arduino PIN8 |
Table 4 Seven Segment Enable Pins |
EN2=0; //RED OFF, Junction Active
A=1; //Select Green
B=1; //Select Green
1 comment:
Traffic Light controller for Engineering students.
For Images log on to
http://www.facebook.com/photo.php?fbid=202052573169479&set=a.202052206502849.53611.159185537456183&type=1&ref=nf
Post a Comment