Binary count down help

lamxe

Senior Member
Code:
;***BINARY COUNT DOWN from 255 to 0  ***

 # picaxe 20m
main:
  if pin0=0 then goto main;if button is not pressed then go back.
    pause 50     

 dec b0    ''''' Star count  from 255 to 0,    decrement a variable 

    wait_for_butn_release:
     if pin0=1 then goto wait_for_butn_release     '''''prevent repeating while button is held down.
       pause 50
 goto main

Dear All..
I tried to change ( dec b0 ''''' Star count from 255 to 0, decrement a variable ) by (
For counter=7 to 0 step-1 ;Start at 7 loop to 0
let pins = counter ;Output count on outport
pause 500 ;Pause 0.5 seconds
Next counter) in this code. For count down from 7 to 0( not 255 to 0. )But have no success. Could you help me to know how modifier this code for count down 7 to 0 with button command.Thank you so much.
lamxe
 
Last edited:

nick12ab

Senior Member
Try this:
Code:
;***BINARY COUNT DOWN from 7 to 0  ***

 #picaxe 20m
load:
    b0 = 7
main:
    if b0 = 255 then load
    if pin0=0 then goto main;if button is not pressed then go back.
    pause 50
    dec b0    ''''' Star count  from 255 to 0,    decrement a variable 

wait_for_butn_release:
    if pin0=1 then goto wait_for_butn_release     '''''prevent repeating while button is held down.
    pause 50
    goto main
It isn't an adaptation of your non-working code as I started modification before you posted it.
 
Top