My problem is timing loops, can you only have one (so everything detecting input's
has to run in the same loop) or can you have more than one?
I have a LED blinking off/on every second, But when the pushbutton is pushed and
it start's running that part of the program the LED stop's blinking untill it returns
back to the main loop. Any way i can have it blinking while its running the pushbutton
part of the program?
Code: Select all
do
{{
// Power Led (Running)
PORTD.F0 = 1; // LED on
Delay_ms(1000); // 1 sec delay
Lcd_out(2,1, "Press For Lights");
PORTD.F0 = 0; // LED off
Delay_ms(1000); // 1 sec delay
}
{
Lcd_cmd(_lcd_clear);
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
Lcd_out(1,1, "Emergency Lights");
Lcd_out(2,1, "***System Ok!***");
if(PORTC.F0 == 0) // If the switch is pressed
{
Delay_ms(100); // Switch Debounce
if(PORTC.F0 == 0) // If the switch is still pressed
{
Lcd_cmd(_lcd_clear);
Lcd_out(1,1, "Switch Pressed");
Lcd_out(2,1, "** Lights On **");
PORTD.F1 = 1; // RD1 ON
Delay_ms(2000); // 5 Second Delay
PORTD.F2 = 1; // RD2 ON
Delay_ms(2000); // 5 Second Delay
PORTD.F3 = 1; // RD3 ON
Delay_ms(2000); // 5 Second Delay
PORTD.F4 = 1; // RD4 ON
Delay_ms(2000); // 5 Second Delay
PORTD.F4 = 0; // RD4 ON
Delay_ms(2000); // 5 Second Delay
PORTD.F3 = 0; // RD3 Off
Delay_ms(2000); // 5 Second Delay
PORTD.F2 = 0; // RD2 Off
Delay_ms(2000); // 5 Second Delay
PORTD.F1 = 0; // RD1 Off
Delay_ms(2000); // 5 Second Delay
}
}
}
}while(1); // Endless Loop
}