hello, trying to get help with my school project to program a simple traffic lights with pedestrian crossing. I'm using PICkit2 with MPLAB IDE. Set-up PORTB as input (buttons) & PORTC as output (LEDs)
I believe after this it will loop back again to the top...
Thank you for the help in advance.
Rich (BB code):
void main (void)
{
initPORT(); // PIC IO Port Configuration and Initialisation
while(1)
{
RC0 = 0; //red light off
RC1 = 0; //amber light off
RC2 = 1; //green light on
RC4 = 1; //red-man on
RC6 = 0; //green-man off
if (RB0 ==1 || RB2==1) //button 0 or button 2 pressed
{
__delay_ms(10000);
RC0 = 0; //red light off
RC1 = 1; //amber light on
RC2 = 0; // green light off
RC4 = 1; //red-man on
RC6 = 0; //green-man off
__delay_ms(3000);
RC0 = 1; //red light on
RC1 = 0; //amber light off
RC2 = 0; //green light off
RC4 = 0; //red-man off
RC6 = 1; //green-man on
__delay_ms(10000);
RC0 = 1; //red light on
RC1 = 0; //amber light off
RC2 = 0; //green light off
RC4 = 0; //red-man off
RC6 = 1; //I need the green-man to blink for 10 seconds (on for 1sec & off for 1sec... 5times) but not sure what to input here!!!
Followed by...
RC0 = 1; //red light on
RC1 = 0; //amber light off
RC2 = 0; //green light off
RC4 = 1; //red-man on
RC6 = 0; //green-man off
__delay_ms(2000);
}
}
}
Thank you for the help in advance.
Last edited by a moderator: