Connect push button to gpio
-
Hi,
what is the best way to connect a push button or a drycontact to gpio of the wypi 2.0 without external resistor.
Does setting the pullup resistor on the gpio and connecting the pin through the push button to gnd work?
Is there a resource where externalwiring of the wipy is described? -
@overlander
Hi,Did you get an answer to your question or can you share how you did it? I need to do the same and if I can reuse what has already been investigated, I can win a lot of valuable time.
Thx! -
@fsergeys
look at any sample for arduino - all are valid for pycom boards only voltage 3V3 is many times difference.
https://www.arduino.cc/en/Tutorial/InputPullupSerial

PS. interesting that i ommit this post 4 months ago..
-
@fsergeys
Hi,
it is like in the graphic of Livius above.
you have to connect the input pin of the pycom device throug your switch(or dry contact,pushbutton....)to GND.
When the pushbutton is not pushed the input of the pycom device is pulled to high(through an internal resistor if pullup resistor is enabled).
When the button is pressed the input is pulled to low.
No external resistors are needed. -
Thx for the replies.
I played around with it connecting P3 and GND to a button, but what I noticed is that a single push sometimes launches multiple callbacks.
Even is put a sleep of 2 s in the function called back, it still happens.
What could be the reason and how can I can around that? -
@fsergeys
when the callbackfunction is triggered wait for 100ms,then check the status of the input-if it is still pulled to low then the button is pressed,else the button is not pressed and you jump out of the callbackfunction.
the reason the callbackfunction is triggered multiple times is the bouncing of the mechanical contact of the switch.
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better 💗
Register Login