Please select To the mobile version | Continue to access the desktop computer version


Hot search: orangepi
View: 394|Reply: 0

How to use push buttons with Orange ?

[Copy link]








Rank: 1

Post time 2019-9-2 21:50:50 | Show all posts |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 the 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

You have to log in before you can reply Login | Register

Points Rules

Archiver|Mobile edition|Darkroom|OrangePi En ( 粤ICP备14086627号-2

2019-10-21 18:10 GMT+8 , Processed in 0.028368 second(s), 23 queries .

Powered by Discuz! X3.2

© 2014-2015 orangepibbs en.

Quick Reply To Top Return to the list