/* ************************* PROJECT *************************** DEMO OF TRAFFIC LIGHTS *******************************************************************/ // HEADER FILES USED #include #include #include #include // FUNCTIONS USED void introduction1(); void introduction2(); void projectwork(); void closing(); void main() { int gd=DETECT,gm,x,y; initgraph(&gd,&gm,"c:\\turboc3\\bgi"); //Initializing Graphics Mode introduction1(); introduction2(); projectwork(); closing(); getch(); closegraph(); restorecrtmode(); } /* FUNCTION INTRODUCTION 1 **************** INTRODUCTORY PAGE (1) ******************* To display the Name of the Programmer ***************************************************************** */ void introduction1() { setbkcolor(BLUE); setcolor(YELLOW); delay(1000); settextstyle(7,HORIZ_DIR,7); outtextxy(200,50,"Project "); setcolor(WHITE); delay(1000); outtextxy(240,150,"in C"); delay(1000); outtextxy(270,250,"by"); setcolor(YELLOW); delay(1000); settextstyle(7,HORIZ_DIR,7); outtextxy(100,350,"Manuj Arora"); delay(2000); cleardevice(); // Clearing the Introduction Page } /* FUNCTION INTRODUCTION 2 **************** INTRODUCTORY PAGE (2) ******************** To display the Welcome Page of "Project" ****************************************************************** */ void introduction2() { setbkcolor(BLUE); // Starting Introduction Page (2) setcolor(YELLOW); delay(1000); settextstyle(7,HORIZ_DIR,6); outtextxy(200,50,"Welcome"); setcolor(WHITE); delay(1000); outtextxy(270,150,"to"); delay(1000); outtextxy(190,250,"demo of"); setcolor(YELLOW); delay(1000); outtextxy(90,360,"STOP LIGHTS"); delay(2000); cleardevice(); // Clearing the Introduction Page(2) } /* FUNCTION *********************** PROJECT WORK ******************************* INVOLVES THE ACTUAL CODING FOR THE PROJECT ************* Working of DIGITAL TIMER ***************** It is 5 Seconds delay Timer for which Light remains RED ********************************************************** Changing the COLOUR of LIGHTS Colour Changes To Yellow when Timer is Zero then To Green ************************************************************* Displaying the INSTRUCTION Message Changes the Instruction from WAIT! to READY ! and then to GO! ***********************************************************************/ void projectwork() { setbkcolor(BLACK); // Starting the Project setcolor(WHITE); settextstyle(7,HORIZ_DIR,2); //To Display Timer Block outtextxy(185,60,"DIGITAL TIMER"); setcolor(YELLOW); outtextxy(205,385,"INSTRUCTION"); //To display Instruction Block setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,130,BLUE); setcolor(BLUE); rectangle(220,170,320,370); setfillstyle(1,WHITE); floodfill(260,250,BLUE); setcolor(BLUE); rectangle(215,415,355,455); setfillstyle(1,RED); floodfill(260,430,BLUE); setcolor(WHITE); settextstyle(7,HORIZ_DIR,4); outtextxy(230,415,"!STOP!"); // To display the Instruction - Wait! setcolor(BLUE); circle(270,210,25); setfillstyle(1,RED); floodfill(280,220,BLUE); circle(270,270,25); circle(270,330,25); //Starting the Timer setcolor(RED); settextstyle(1,HORIZ_DIR,5); outtextxy(250,90,"10"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"9"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"8"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"7"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"6"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); settextstyle(1,HORIZ_DIR,5); outtextxy(260,90,"5"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"4"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"3"); delay(1000); setcolor(BLUE); setfillstyle(1,YELLOW); rectangle(190,90,350,140); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"2"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"1"); delay(1000); setcolor(BLUE); rectangle(190,90,350,140); setfillstyle(1,YELLOW); floodfill(200,110,BLUE); setcolor(RED); outtextxy(260,90,"0"); // Ending the Timer setcolor(BLUE); rectangle(215,415,355,455); setfillstyle(1,RED); floodfill(260,430,BLUE); setcolor(WHITE); settextstyle(7,HORIZ_DIR,4); outtextxy(220,415,"!READY!"); //To display Instruction-READY! setcolor(BLUE); setfillstyle(1,WHITE); floodfill(280,220,BLUE); setfillstyle(1,YELLOW); floodfill(280,280,BLUE); delay(3000); setcolor(BLUE); rectangle(215,415,355,455); setfillstyle(1,RED); floodfill(260,430,BLUE); setcolor(WHITE); settextstyle(7,HORIZ_DIR,4); outtextxy(260,415,"!GO!"); //To Display Instruction-GO! setfillstyle(1,WHITE); floodfill(280,290,BLUE); setfillstyle(1,GREEN); floodfill(280,350,BLUE); delay(5000); cleardevice(); //Ending the Project } void closing() { setbkcolor(YELLOW); setcolor(BLUE); settextstyle(7,HORIZ_DIR,4); outtextxy(160,180,"!! THANK YOU !!"); outtextxy(120,280," Press any key to EXIT"); }