I am trying to write my first program for a picaxe 40x2
I have 1 input button switch (momentary) connected to Pin C.1
I have 10 LED's connected to Pins #1 = D.6, #2 = D.7, #3 = B.0, #4 = B.1 , #5 = B.2, # 6 = B.3 , #7 = B.4 , #8 = B.5 , # 9 = B.6 and # 10 or (0) = B.7
I need the program to count how many times the button is pushed within a certain length of time (I have been using 5 seconds) and then turn on the appropriate
led ( the one that numerically corrresponds to the count) .
Like, if the button it pushed 3 times within the time interval, then led #3 turns on (pinB.0 goes high)
not haveing too much luck so far,,,
Below is the code I have written using the "Count" example in the manual as a base to work from.
I someone could point me in the right direction I would really appreciate it!
Thanks!
Randy
I have 1 input button switch (momentary) connected to Pin C.1
I have 10 LED's connected to Pins #1 = D.6, #2 = D.7, #3 = B.0, #4 = B.1 , #5 = B.2, # 6 = B.3 , #7 = B.4 , #8 = B.5 , # 9 = B.6 and # 10 or (0) = B.7
I need the program to count how many times the button is pushed within a certain length of time (I have been using 5 seconds) and then turn on the appropriate
led ( the one that numerically corrresponds to the count) .
Like, if the button it pushed 3 times within the time interval, then led #3 turns on (pinB.0 goes high)
not haveing too much luck so far,,,
Below is the code I have written using the "Count" example in the manual as a base to work from.
I someone could point me in the right direction I would really appreciate it!
Thanks!
Randy
Code:
#picaxe 40x2
main:
count C.1, 5000, w1 ; count pulses in 5secs
debug ; display value
if w1 = 1 then
high D.6
debug
elseif w1 = 2 then
high D.7
debug
elseif w1 = 3 then
high B.0
debug
elseif w1 = 4 then
high B.1
debug
elseif w1 = 5 then
high B.2
debug
elseif w1 = 6 then
high B.3
debug
elseif w1 = 7 then
high B.4
debug
elseif w1 = 8 then
high B.5
elseif w1 = 9 then
high B.6
debug
elseif w1 = 10 then
high B.7
debug
end if
wait 2
'turns off the leds so button can be used again
low D.6
low D.7
low B.0
low B.1
low B.2
low B.3
low B.4
low B.5
low B.6
low B.7
goto main
Last edited by a moderator: