Professional Documents
Culture Documents
Faculty of Computer Science BCS Subject: PLC Major Assignment (Individual)
Faculty of Computer Science BCS Subject: PLC Major Assignment (Individual)
Faculty of Computer Science BCS Subject: PLC Major Assignment (Individual)
BCS
Subject: PLC
Major Assignment
(Individual)
BY:
Mr. MOHAMMAD YOUSUF NABIZAD
Reg#: 201-2309009
Page 1 of 4
Introduction:
• We used Dev++ to compile a simple project about traffic lights
controlling system.
• We have 3 main lights Red, yellow, Green each one is going to
be on and off according to program.
• Every light has their own specified delay or sleep time.
• FOR loop is used for the reputed execution of the program.
Project Code:
#include<iostream>
#include<windows.h>
#include<graphics.h>
main()
{
initwindow(800, 800);
rectangle(250, 50, 350, 350);
circle(300, 100, 50);
circle(300, 200, 50);
circle(300, 300, 50);
//creating animation
for(int i =0; i < 10; i++){
Page 2 of 4
setfillstyle(1, RED);
floodfill(300, 100, WHITE);
outtextxy(280, 100, "STOP");
delay(5000);
setfillstyle(1, BLACK);
floodfill(300, 100, WHITE);
setfillstyle(1, YELLOW);
floodfill(300, 200, WHITE);
outtextxy(280, 200, "Ready");
delay(3000);
setfillstyle(1, BLACK);
floodfill(300, 200, WHITE);
setfillstyle(1, GREEN);
floodfill(300, 300, WHITE);
outtextxy(280, 300, "GO");
delay(5000);
setfillstyle(1, BLACK);
floodfill(300, 300, WHITE);
}
getch();
closegraph();
Page 3 of 4
}
Page 4 of 4