traffic light

Thread Starter

ericparggah

Joined Jan 2, 2009
1
Hello everyone,
I am working on a four way traffic light controller using the PIC16F877A and WIZ-C version 17. The clock is 5.5MHz. I want the RED LED and GREEN LEDs to stay on for Two minutes and the AMBER to stay on for about 5seconds. I am having a problem with the timing. I realized i cannot implement delays of more than 1000ms or so. Is there any way around it?
 

t06afre

Joined May 11, 2009
5,934
You may use counter variables. And do x needed 1000ms delays before you change the states.
By the way do not hijack other threads in this forum.
 

spinnaker

Joined Oct 29, 2009
7,830
Hello everyone,
I am working on a four way traffic light controller using the PIC16F877A and WIZ-C version 17. The clock is 5.5MHz. I want the RED LED and GREEN LEDs to stay on for Two minutes and the AMBER to stay on for about 5seconds. I am having a problem with the timing. I realized i cannot implement delays of more than 1000ms or so. Is there any way around it?
Why are you hijacking someone else's thread?
 

mjhilger

Joined Feb 28, 2011
118
I almost always set up a timer tic using timer 0 or 1 for 1ms or 10ms. There is probably sample code on how to implement a timer with an interrupt. You can dial in the exact count for the timer to get the time required. Use a global variable and set its value to be decremented in the timer tic interrupt routine. This gives you freedom in the main loop and the processing power at that point to use multiple variables to count any length of time you desire. You look in the main loop for the count of your global counting variable to hit 0 and do your thing. Then when you change states, set your global variable to the beginning number to count down from again.
 
Top