
Patrick B. answered 01/20/21
Math and computer tutor/teacher
You will need at least FOUR (4) Timers.....
TimerMain has interval of 9000ms, 7000ms, or 3000 ms
to control the state of the LEDs
TimerBuzzer has interval of 500, to control the buzzer
TimerOneShot has interval of 2000
TimeCountdown has interval of 1000 to control the time remaining
If you cannot change the timer interval of the timers then you will need SIX (6)
timers: timerRED, timerYELLOW, timerGREEN, timerBUZZER, timerOneSHot, timerCountDown
You will also need to store the value of the Countdown, 7,6,5,4,3,2,1 in a register.
You may also need to store the value of along STATE of the program: 0=red, 1=yellow, 2=green,
which is MOD 3....
if so, then on each main timer event, STATE=(STATE+1) mod 3
Although I do not have the hardware for this embedded system, here is the logic behind the timer events.
//****************** 'Initial Startup
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
redLight.Visible = False
yellowLight.Visible = False
greenLight.Visible = True
LabelBuzzer.Visible = False
TimerMain.Interval = 9000
TimerMain.Enabled = True
TimerBuzzer.Enabled = False
LabelBuzzer.Visible = False
TimerCountdown.Interval = 1000
TimerCountdown.Enabled = True
TimerOneShot.Interval = 2000
TimerOneShot.Enabled = True
iCount = 7
End Sub
Private Sub TimerMain_Tick(sender As System.Object, e As System.EventArgs) Handles TimerMain.Tick
If (redLight.Visible) Then
redLight.Visible = False
yellowLight.Visible = True
TimerMain.Interval = 3000
TimerBuzzer.Enabled = False
LabelBuzzer.Visible = False
TimerCountdown.Enabled = False
LabelCountdown.Visible = False
ElseIf (yellowLight.Visible) Then
yellowLight.Visible = False
greenLight.Visible = True
TimerMain.Interval = 9000
TimerOneShot.Enabled = True
Else
greenLight.Visible = False
redLight.Visible = True
TimerMain.Interval = 7000
TimerBuzzer.Interval = 500
TimerBuzzer.Enabled = True
LabelBuzzer.Visible = True
End If
End Sub
Private Sub TimerBuzzer_Tick(sender As System.Object, e As System.EventArgs) Handles TimerBuzzer.Tick
If LabelBuzzer.Visible = True Then
LabelBuzzer.Visible = False
Else
LabelBuzzer.Visible = True
End If
End Sub
Private Sub TimerOneShot_Tick(sender As System.Object, e As System.EventArgs) Handles TimerOneShot.Tick
TimerOneShot.Enabled = False
TimerCountdown.Enabled = True
LabelCountdown.Text = 7
LabelCountdown.Visible = True
End Sub
Private Sub TimerCountdown_Tick(sender As System.Object, e As System.EventArgs) Handles TimerCountdown.Tick
LabelCountdown.Text = iCount
iCount = iCount - 1
If (iCount = 0) Then iCount = 7
End Sub
Cuko T.
thank you so much01/26/21