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?



  • @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.



  • 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
    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.



  • @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
    alt text

    PS. interesting that i ommit this post 4 months ago..



  • @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!


Log in to reply
 

Pycom on Twitter