Skip to content

Simple button is not working #9328

Discussion options

You must be logged in to vote

I figured it out.

For future reference, this worked for me:

from machine import Pin

btn = machine.Pin(0, machine.Pin.IN, machine.Pin.PULL_DOWN)

last_state = False
current_state = False

while True:
    current_state = btn.value()
    if last_state == False and current_state == True:
        print ('pushed')
    last_state = current_state

Thanks to everyone that replied!

Replies: 7 comments 4 replies

Comment options

You must be logged in to vote
1 reply
@greenreader9
Comment options

Comment options

You must be logged in to vote
1 reply
@greenreader9
Comment options

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@greenreader9
Comment options

Comment options

You must be logged in to vote
1 reply
@puppet13th
Comment options

Answer selected by greenreader9
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
6 participants