I'm starting a new project and have a short bit of code that I'd like to be more responsive.
An 08M should blink a series of three LEDs while waiting for a button to be pressed. When it's pressed it will then trigger an MP3 (played via the Tenda MP3 board) and change the pattern of blinking LEDs. My first pass at this is to have one LED blink, wait for the button press and then trigger another LED. However, I find that my first instance of this code is not that responsive - I have to hold down the button for a couple of seconds to get the second LED to trigger.
How can this be improved? I figure there's a better way. Thanks for any insight!
An 08M should blink a series of three LEDs while waiting for a button to be pressed. When it's pressed it will then trigger an MP3 (played via the Tenda MP3 board) and change the pattern of blinking LEDs. My first pass at this is to have one LED blink, wait for the button press and then trigger another LED. However, I find that my first instance of this code is not that responsive - I have to hold down the button for a couple of seconds to get the second LED to trigger.
How can this be improved? I figure there's a better way. Thanks for any insight!
Code:
; *******************************
; Filename: LED Blinker and button test
; Date:
; File Version:
; Written by: Jeff Haas
; Function:
; Last Revision: 3/19/2012
; Target PICAXE: 08M
; *******************************
#picaxe 08M
#no_end
SetFreq m8 'Required for Tenda board communication
symbol PBUTTON = pin3 'Assigns pin3 to Button.
main:
b0 = 0 'Set byte 0 to 0
readadc 2,b0
pause 5 'Brief pause on the checking loop
b0 = b0 + 5 * PBUTTON 'Add 5 to byte 0 and multiply by value of PBUTTON. Button pressed = high value.
debug b0
high 2 'Blink first LED as "idle" state
pause 1000
low 2
pause 1000
if b0 < 1 then Main
high 4 'Blink second LED to show button has been pressed
pause 1000
low 4
pause 500
goto main