Multiple push buttons - Raspberry

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
Hi,

What is the best way to implement an algorithm to read 6 push buttons, debounce them, and do something according to the button pressed? Interrupts or polling mode? I would appreciate any resource you could provide.

Thank you.
 

John P

Joined Oct 14, 2008
2,026
I'm always in favor of polling controls, and doing it at a rate that's slow enough that you don't need to worry about debouncing at all. Something like 40 scans a second is good, where it's not going to be noticeable to the user, but any electrical bouncing can happen between scans.

How to "do something according to the button pressed" depends totally on what that something is.
 

Thread Starter

Xavier Pacheco Paulino

Joined Oct 21, 2015
728
I'm always in favor of polling controls, and doing it at a rate that's slow enough that you don't need to worry about debouncing at all. Something like 40 scans a second is good, where it's not going to be noticeable to the user, but any electrical bouncing can happen between scans.

How to "do something according to the button pressed" depends totally on what that something is.
I'm just going to send serial data. For example, if button 1 is pressed, then transmit "1" to another microcontroller.
 
Top