Picaxe 08M2 countdown timer

louislouis

New Member
Hi guys,
I'm new on the forum, and also an PICAXE novice.
I needed a simple 0 to 99 sec. countdown timer. So, I try to do this with picaxe.
I use PICAXE 08M2, two common cathode seven segment display and two serial shift registers 74HC595.
Also I use PIN C.3 like output with simple NPN transistor and two resistors.
Input is realized via three pushbutton with ADC input on picaxe.
Button one increment, button two decrement the value if pressed both buttons the value is reset to zero.
Button three is the start and stop countdown.
Here is a short video how the prototype works:

https://www.youtube.com/watch?v=H7qwa_a50po&feature=youtu.be

Here is the source code:

Code:
main:
pullup off
readadc 4,b11
if b11=128 or b11=127 then inc b8 endif
if b11=103 then dec b8 endif
if b8=100 then let b8=0 endif
if b8=255 then let b8=99 endif
if b11=71 and b8>0 then  star
if b11=73 or b11=74 then let b8=0 endif
pause 10
gosub dat 
high 0 ;latch, show data on display
low 0
goto main

odpocet:
pullup $08
dec b8
gosub dat
for b12=1 to 250
pause 1
readadc 4,b11
if b11=71 then goto stp
next b12
high 0 ;latch, show data on display
low 0
if b8>0 then goto odpocet
if b8=0 then goto main
goto odpocet

dat:
let b4=b8//10 ;extract and show 1's
gosub display
let b4=b8/10 ;extract and show 10's
gosub display
return

stp:
pullup off
readadc 4,b11
if b11<>71 then goto main
goto stp

star:
readadc 4,b11
if b11<>71 then goto odpocet
goto star

display:
lookup b4, (%11111100,%01100000,%11011010,%11110010,%01100110,%10110110,%10111110,%11100000,%11111110,%11110110,%00000000),w0 ;define seven segment characters
low 2
low 0
low 1
for b2=1 to 8
b3=w0 and %00000001 ;bit status
if b3=0 then low 1 else high 1 endif
high 2
low 2
let w0=w0/2 ;shift bits to place
next b2
return
 
Last edited:
Top