You are on page 1of 11

TRAFFIC SIGNAL

INDEX :-

SR.NO TITLE PAGE.NO

1 Introduction 2-3

2 Code 4-9

3 Cutput 10

4 Conclusion 11

VVIT,PAL 1
TRAFFIC SIGNAL

INTRODUCTION :-

Traffic lights are also named as stoplights, road traffic lamps, traffic
signals, stop-and-go lights which are signaling devices placed at road
crossings, everyday pedestrian crossings and other locations to
control competing flows of traffic. Traffic lights havebeen fixed
allover the world in many cities. Traffic light control assigns a right
way to the road users by using lights in normal colors (red –
amber/yellow – green)

uses a worldwide color code (a specific color order to enable


color recognition for those who are color blind)

VVIT,PAL 2
TRAFFIC SIGNAL

In China, there were unsuccessful efforts to change the importance


of “red” to “go” during the Cultural Revolution. Typically traffic
lights consist of three types of colored lights such as red, orange
and green. In a typical cycle, turning on of agreen light allows
traffic to continue in the way indicated.
Similarly,lighting of the amber/orange light for a short time of
transition represents a signal to prepare to stop, and the Illumination
of the red signal disallows any traffic from going on.

This traffic light control system can be further enhanced in such away
to control the traffic signals automatically based on the traffic density
on roads with the help of IR sensor modules with automatic turnoff if
there are no vehicles on either side of the roadwhich leads to power
consumption.

The main objective of this traffic light controller is to provide


sophisticated control and coordination to confirm that traffic moves
as smoothly and safely as possible

VVIT,PAL 3
TRAFFIC SIGNAL

CODE :-

/ C++ program for the above approach


#include <conio.h>
#include <dos.h>
#include <graphics.h>
#include <iostream.h>
#include <stdlib.h>

void main()
{

clrscr();

int gd = DETECT, gm, midx, midy;

// Passed three arguments to the

// initgraph function to initialize

// graphics mode

initgraph(&gd, &gm, "C:\\TC\\BGI");

VVIT,PAL 4
TRAFFIC SIGNAL

midx = getmaxx() / 2;

midy = getmaxy() / 2;

// Set color of intro text as cyan

setcolor(CYAN);

// Below just styling the text settextstyle(TRIPLEX_FONT,

HORIZ_DIR, 4); settextjustify(CENTER_TEXT,

CENTER_TEXT);

outtextxy(midx, midy - 10, "TRAFFIC LIGHT SIMULATION");

outtextxy(midx, midy + 10, "PRESS ANY KEY TO START");

getch();

cleardevice();

setcolor(WHITE);

settextstyle(DEFAULT_FONT, HORIZ_DIR, 1);

VVIT,PAL 5
TRAFFIC SIGNAL

// rectangle lines

rectangle(midx - 30, midy - 80, midx + 30, midy + 80);

// Circle for red light circle(midx,

midy - 50, 22);

setfillstyle(SOLID_FILL, RED);

floodfill(midx, midy - 50, 22);

setcolor(BLUE);

// Text inside red light outtextxy(midx,

midy - 50, "STOP");

// Delay of 2 sec

delay(2000);

graphdefaults();

cleardevice();

VVIT,PAL 6
TRAFFIC SIGNAL

setcolor(WHITE);

// Drawing lines of rectangle

// for traffic light rectangle(midx

- 30, midy - 80,

midx + 30, midy + 80);

// Drawing yellow circle for light

circle(midx, midy - 50, 22);

setfillstyle(SOLID_FILL, YELLOW);

floodfill(midx, midy, WHITE);

setcolor(BLUE);

// Setting inner text to ready outtextxy(midx

- 18, midy - 3, "READY");delay(2000);

VVIT,PAL 7
TRAFFIC SIGNAL

cleardevice();

setcolor(WHITE);

// Drawing lines of rectangle

// for traffic light rectangle(midx

- 30, midy - 80,

midx + 30, midy + 80);

// Circle for green light circle(midx,

midy + 50, 22);

setfillstyle(SOLID_FILL, GREEN);

floodfill(midx, midy + 50, WHITE);

setcolor(BLUE);

// Setting inner text to GO

VVIT,PAL 8
TRAFFIC SIGNAL

outtextxy(midx - 7, midy + 48, "GO");

setcolor(RED);

settextstyle(TRIPLEX_FONT,

HORIZ_DIR, 4);

outtextxy(midx - 150, midy + 100,

"Brrrmmm");

getch();

VVIT,PAL 9
TRAFFIC SIGNAL

OUTPUT:-

VVIT,PAL 10
TRAFFIC SIGNAL

CONCLUSION:-

Light Options - As in any traffic signal you will see the three lights - red,
yellow and green. All the options has been implemented.
Vehicles - To keep the OpenGL Code simple for all only three vehicles has
been added. Though, if you like to add more do it, you are welcome.
Lanes - The right and left lane options is implemented in the program.
User Interactions - Both mouse and keyboard interaction has been added to the
OpenGL Code. All the user interactions has been listed in the post below.
There is options to speed up the traffic is also in the code.
This innovative software projects is an effective traffic signal management
project that allows for managing 4 way traffic signal management system. The
system consists of 4 signals corresponding to each road. We here propose a
density based traffic signal scheduling algorithm. The system is designed to
manage traffic signal timings based on the density of traffic on its corresponding
road. The system represents the traffic strength of a road graphically using
traffic judgments.
This innovative software projects is an effective traffic signal management
project that allows for managing 4 way traffic signal management system.
The system consists of 4 signals.

VVIT,PAL 11

You might also like