While I agree with what LGM says about learning from the beginning, that's not going to happen.
Let's expand on this a little. I won't go beyond this, so I encourage MrDEB to go over this the THINK his way through the steps. What I posted before is a concept to get rid of all the delays that prevent reading switches. Starting from this concept:
First, we'll need to declare variables for EACH LED color.
Code:
Dim RedLEDOn as Boolean
//True means you want the LED on
Dim RedLEDOnTime as Word
//The time you want the LED to be on.
//This can be different each time you turn it on
Dim RedLEDOnTimeCount as Word
//this is a counter of how long the LED has been on
Repeat this for green, yellow, blue....whatever colors you have.
At the end of your program loop, we put the following, a separate block for each color.
Code:
If RedLEDOn = true then
inc(RedLEDOnTimeCount)
if (RedLEDOnTimeCount > RedLEDOnTime then
RedLEDOn = False
RedLED = (whatever state turns it off)
RedLEDOnTimeCount = 0
end if
end if
If GreenLEDOn = true then
inc(GreenLEDOnTimeCount)
if (GreenLEDOnTimeCount > GreenLEDOnTime then
GreenLEDOn = False
GreebLED = (whatever state turns it off)
GreenLEDOnTimeCount = 0
end if
end if
//repeat the block for all colors
And finally you can either add THE ONLY DELAY IN THE LOOP or the timer routine to generate 1mS events. Let's go the delay route.
The above code handles only keeping the LEDs on the length of time you want them on. Read it. Think about what happens when you want an LED or several LEDs on. Take your time. I will wait until you understand it.
Stop. Do what I said. Line by line, go through the above until you understand what's happening.
Understand it? Ok, now we move on to turning on LEDs on. Nothing changes in your logic of the switches. That part is on you.
If I recall, you turn on the green LED for 3 seconds to start the process. We need a few lines to do that.
Code:
If (switch pressed) then //this part is on you
GreenLEDOnTime = 3000
GreenLEDOn = True
GreenLED = (whatever turn it on)
End If
When this gets to the block at the end, the block at the end will keep track of how long the LED is on, and turn it off at the right time.
Let's say somebody presses the switch too early. The logic is on you, but this is how you control the LEDs.
Code:
If (button pressed too early) then
RedLEDOnTime = 5000
RedLEDOn = True
RedLED = (whatever turns it on)
GreenLEDOn = false
GreenLED = (whatever turns it off)
//required since the LED didn't time out
I hope this helps. I urge you to go through this step by step, as many times as it takes to understand it.
I'm not going to help you with your logic or anything other than turning the LEDs on for the desired time. This is as clear as I can make it.