Button released

lamxe

Senior Member
Code:
; Picaxe 08m
Main:
 IF pin1= 1 then goto Marche
 IF pin2= 1 then goto Arret
           goto main
Marche:
       High 0
       goto main
Arret:
       Low 0
      goto main
Dear All
This code for driver a led or motor ,commands by push button in mode PRESSED . Please help me to have another code in mode RELEASED ( led on or off when a button is release) many thank you .
Best regards
 
Last edited:

hippy

Ex-Staff (retired)
Do not immediately 'goto main'; wait until the pin goes low -

Code:
Marche:
       High 0
       if pin1=1 goto Marche
       ; button released
       goto main
 

lamxe

Senior Member
Code:
; Picaxe 08m
Main:
 
 IF pin2= 1 then goto Arret
   IF pin1= 1 then goto Marche
      
           goto main
 Marche:
       
    IF pin1= 1 then goto Marche
       ; button released
       high 0
       goto main
Arret:
      IF pin2= 1 then goto Arret ;; button released
       Low 0
      goto main
Dear Hippy
This is the code from you guide me . Very simple and high-performance for me.Thank you so much for your time help me.
Best regards
lamxe
 

westaust55

Moderator
If you seek the change of state only to occur when the button is released then try:
Code:
Marche:
  iF pin1 = 1 THEN Marche ; loop/wait while pin1 remains high
  HIGH 0
  GOTO Main
 
Top