9acca9
Posts: 13
Joined: Sun Sep 18, 2016 11:20 pm

Released button.

Tue Jun 12, 2018 7:52 pm

Hi.Could someone pass me a code to print "Button released" ???

The truth is that I was testing several codes and I can not find the correct one.

In other words, the message "Button released" appears when a button that is always closed is released.

Greetings and many thanks

this is my button.

Image

User avatar
B.Goode
Posts: 8233
Joined: Mon Sep 01, 2014 4:03 pm
Location: UK

Re: Released button.

Tue Jun 12, 2018 7:58 pm

The gpiozero python library module has a basic 'recipe' that demonstrates this: https://gpiozero.readthedocs.io/en/stab ... tml#button

(Scroll down to after the blue 'Note', where it says "Similarly, functions can be attached to button releases:")

User avatar
Z80 Refugee
Posts: 358
Joined: Sun Feb 09, 2014 1:53 pm

Re: Released button.

Wed Jun 13, 2018 9:34 am

Your button will not be reliable unless it is wired correctly. See the link below, and scroll down to "Hardware Interfacing".

viewtopic.php?f=34&t=207597
Military and Automotive Electronics Design Engineer (retired)

For the best service: make your thread title properly descriptive, and put all relevant details in the first post (including links - don't make us search)!

texy
Forum Moderator
Forum Moderator
Posts: 5155
Joined: Sat Mar 03, 2012 10:59 am
Location: Berkshire, England

Re: Released button.

Wed Jun 13, 2018 11:12 am

9acca9 wrote:
Tue Jun 12, 2018 7:52 pm
Hi.Could someone pass me a code to print "Button released" ???

The truth is that I was testing several codes and I can not find the correct one.

In other words, the message "Button released" appears when a button that is always closed is released.

Greetings and many thanks

this is my button.

Image
Hi,
you need to confirm which language you are using, the assumption is python, in which case, B.Goode has shown a good link to help.
Also with any Input you need to be aware of 'floating' pins, so if pull-ups are not utilised, either internal or external, then you may not be getting the results you expect.
Texy
Various male/female 40- and 26-way GPIO header for sale here ( IDEAL FOR YOUR PiZero ):
https://www.raspberrypi.org/forums/viewtopic.php?f=93&t=147682#p971555

hippy
Posts: 5760
Joined: Fri Sep 09, 2011 10:34 pm
Location: UK

Re: Released button.

Wed Jun 13, 2018 11:15 am

In pseudo code ...

Code: Select all

Do
  Do : Loop until Input == 0
  Print "Button pushed"
  Do : Loop until Input != 0
  Print "Button released"
Loop
Change the 0's to 1's if it's working the wrong way round, showing "release" when pushed.

Return to “General discussion”