View: 7837|Reply: 1

How to use push buttons with Orange ?

[Copy link]

3

threads

3

posts

27

credits

Novice

Rank: 1

credits
27
Published in 2019-9-2 21:50:50 | Show all floors |Read mode
Hi there,

In my project, I need 3 push buttons attached to OrangePi.
Theses buttons are tied to changing the behavior of the software.

When someone press (and release) one of theses buttons, the original configuration is restaured (whatever that means).
When another button is pressed a pre-configured mode is setup.
And when a third button is pressed another configuration is activated. You got the ideia.

I am using the 3.3V GPIO pins to plug a push button.
A infinite loop on a python program detects when a specific button is pressed.
  1. while True:
  2.     if (gpio.input(23) == 1 ):
  3.         print ("button was pressed. Do something usefull")
  4.     time.sleep (1)
  5. gpio.cleanup ()
Copy code
It is working.
But the question is about the right way of doing things. Is the infinite loop the best approach ? Is it not a time consuming operation ?
I was looking for a event based, kernel fired approach...Is it possible ?
Related to that, how to implement a hardware reset button that works even when the OS is borked ? Kind of a  watchdog reset ? Much like the reset button we have on our computers...? Is it possible ?

best regards

27

threads

58

posts

2172

credits

Gold member

Rank: 6Rank: 6

credits
2172
Published in 2019-11-1 00:16:09 | Show all floors
It is best to activate the internal pull-up, set the debounce and switch to GND.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list