Elec Practical
Elec Practical
h>
void main(void)
{
P3 = 0xFF; // Set all P3 pins high initially
P2 = 0xFF; // Set all P2 pins high initially
while(1)
{
// North direction traffic light sequence
NR = OFF;
NG = ON;
Delayms(2000); // North green light for 2 seconds
NG = OFF;
NY = ON;
Delayms(800); // North yellow light for 800 milliseconds
NY = OFF;
NR = ON;
EG = OFF;
EY = ON;
Delayms(800); // East yellow light for 800 milliseconds
EY = OFF;
ER = ON;
SG = OFF;
SY = ON;
Delayms(800); // South yellow light for 800 milliseconds
SY = OFF;
SR = ON;
WG = OFF;
WY = ON;
Delayms(800); // West yellow light for 800 milliseconds
WY = OFF;
WRed = ON;
}
}