1. ericparggah

    Thread Starter New Member

    Jan 2, 2009
    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?
  2. t06afre

    AAC Fanatic!

    May 11, 2009
    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.
  3. spinnaker

    AAC Fanatic!

    Oct 29, 2009
    Why are you hijacking someone else's thread?
  4. beenthere

    Retired Moderator

    Apr 20, 2004
  5. mjhilger

    Senior Member

    Feb 28, 2011
    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.