Countdown

otm

Member
Hi, I am working on a project where I want to use a PICaxe 28 (possibly X) and a AXE033 to produce a countdown system.

The project works by a rotary switch wired to 3 input pins on the Pic. each pin is set to countdown from a different number. 1 of the outputs is wired into an 08M for an alarm tune (there will be a selection of 3 tunes which will be chosen by another rotary switch). Finally 1 other output powers and LED with flashes every second when the timer reaches 5 seconds down till 0 seconds.

I have produced an idea but to repeat it 3 times would be too big.. so, I need help in cutting it down: (Ohh by the way thanks to Phil75, beaniebots, RickHarris, premelec, Arvin and Ibenson for helping me 1 year ago with an edge trigger using variables)

symbol flags = b0
symbol PinState = b1
flags =39

Main:
If pin0 = 0 And bit0 = 1 Then
GoSub output_1
ElseIf pin1 = 0 And bit1 = 1 Then
GoSub output_2
ElseIf pin2 = 0 And bit2 = 1 Then
GoSub Output_3
endif
pause 500
PinState = pins & %00100111
If PinState > flags Then
flags = PinState
Endif
GoTo Main



output_1:
bit0 = 0
serout 7,4,(254,1)
pause 500
serout 7,4,("15:00")
pause 900000
serout 7,4,(254,1)
serout 7,4,("10:00")
pause 600000
serout 7,4,(254,1)
serout 7,4,("5:00")
pause 300000
serout 7,4,(254,1)
serout 7,4,("4:00")
pause 240000
serout 7,4,(254,1)
serout 7,4,("3:00")
pause 180000
serout 7,4,(254,1)
serout 7,4,("2:00")
pause 120000
serout 7,4,("1:00")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":59")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":58")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":57")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":56")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":55")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":54")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":53")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":52")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":51")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":50")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":49")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":48")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":47")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":46")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":45")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":44")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":43")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":42")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":41")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":40")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":39")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":38")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":37")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":36")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":35")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":34")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":33")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":32")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":31")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":30")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":29")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":28")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":27")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":26")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":25")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":24")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":23")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":22")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":21")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":20")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":19")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":18")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":17")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":16")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":15")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":14")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":13")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":12")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":11")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":10")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":09")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":08")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":07")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":06")
pause 1000
serout 7,4,(254,1)
serout 7,4,(":05")
high 1
pause 800
low 1
pause 200
serout 7,4,(254,1)
serout 7,4,(":04")
high 1
pause 800
low 1
pause 200
serout 7,4,(254,1)
serout 7,4,(":03")
high 1
pause 800
low 1
pause 200
serout 7,4,(254,1)
serout 7,4,(":02")
high 1
pause 800
low 1
pause 200
serout 7,4,(254,1)
serout 7,4,(":01")
high 1
pause 800
low 1
pause 200
serout 7,4,(254,1)
serout 7,4,(":00")
high 2
pause 1000
return

etc..

any help will be much appreciated..

Thankyou

Owen
 

hippy

Technical Support
Staff member
Code:
For b0 = 59 To 0 Step -1
  SerOut 7,4,(254,1)
  SerOut 7,4,(":")
  If b0 < 10 Then
    SerOut 7,4,("0")
  End If
  SerOut 7,4,(#b0)
  Pause 1000
Next
Will show seconds decrementing down fro 59 to 0
 

otm

Member
Hey, thats great... can you please explain in detail how it works.... so I can further my knowledge....

and how would I add system to make an LED flash for the last 5 seconds,

eg:
high 1
pause 800
low1
pause 200

to make it flash with a clear distinction between on and off. (If that makes any sense at all.

Cheers

Owen
 
Top