View: 10818|Reply: 2

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

2461

credits

Gold member

Rank: 6Rank: 6

credits
2461
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.

21

threads

144

posts

494

credits

Intermediate member

Rank: 3Rank: 3

credits
494
Published in yesterday 20:12 | Show all floors
This post was finally edited by Olofmeister at 2025-12-22 20:40



Hej, czytając o technicznych rozwiązaniach i szukaniu efektywnych metod, przypomniało mi się, jak sam potrzebowałem prostego sposobu na oderwanie się od codziennego napięcia i zupełnie przypadkiem trafiłem na spino gambino. Dla graczy z Polski dostępne są bonusy, więc mogłem spokojnie przetestować kilka gier w kasynie online. Najpierw była seria przegranych spinów, ale potem zaryzykowałem trochę więcej i wpadła solidna wygrana, która poprawiła mi nastrój. Prosty interfejs i uczciwa rozgrywka naprawdę pozwalają się zrelaksować i oderwać od codziennych obowiązków.
You need to log in before you can reply login | Register

Points Rule

Quick reply Top Return list