On Wed, 23 Jun 2021 08:27:18 +0200, "F. W." <
me@home.com> declaimed the following:
Does anybody know how to get a signal if the button on the pico is
pressed? How can a Python-Program detect that the button is pressed?
As others have already commented as to the actual button, I'll attempt a general review of the second question.
Their are a number of ways to read GPIO pins.
SYSFS:
Old (and being deprecated by Linux development)
https://www.ics.com/blog/gpio-programming-using-sysfs-interface
pi@rpi3bplus-1:~$ ls -l /sys/class/gpio
total 0
-rwxrwx--- 1 root gpio 4096 Jun 19 12:15 export
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip504 -> ../../devices/platform/soc/soc:firmware/soc:firmware:expgpio/gpio/gpiochip504 -rwxrwx--- 1 root gpio 4096 Jun 19 12:15 unexport
pi@rpi3bplus-1:~$ echo "24" >/sys/class/gpio/export
pi@rpi3bplus-1:~$ ls -l /sys/class/gpio
total 0
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 export
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 gpio24 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio24
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip0 -> ../../devices/platform/soc/3f200000.gpio/gpio/gpiochip0
lrwxrwxrwx 1 root gpio 0 Jun 19 12:15 gpiochip504 -> ../../devices/platform/soc/soc:firmware/soc:firmware:expgpio/gpio/gpiochip504 -rwxrwx--- 1 root gpio 4096 Jun 19 12:15 unexport
pi@rpi3bplus-1:~$ ls -l /sys/class/gpio/gpio24
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 /sys/class/gpio/gpio24 -> ../../devices/platform/soc/3f200000.gpio/gpiochip0/gpio/gpio24 pi@rpi3bplus-1:~$ ls -l /sys/class/gpio/gpio24/
total 0
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 active_low
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 device -> ../../../gpiochip0 -rwxrwx--- 1 root gpio 4096 Jun 23 11:41 direction
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 edge
drwxrwx--- 2 root gpio 0 Jun 23 11:41 power
lrwxrwxrwx 1 root gpio 0 Jun 23 11:41 subsystem -> ../../../../../../../class/gpio
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 uevent
-rwxrwx--- 1 root gpio 4096 Jun 23 11:41 value
pi@rpi3bplus-1:~$ echo /sys/class/gpio/gpio24/direction /sys/class/gpio/gpio24/direction
pi@rpi3bplus-1:~$ cat /sys/class/gpio/gpio24/direction
in
pi@rpi3bplus-1:~$ cat /sys/class/gpio/gpio24/value
0
pi@rpi3bplus-1:~$
Since those appear as "files" any application that can open/read-write/close the paths can use it.
libgpiod:
The intended replacement for the sysfs access. Not installed by default (based upon my R-Pi -- attempting apt install of gpiod; though I may have a slightly corrupted apt system.
https://www.ics.com/blog/gpio-programming-exploring-libgpiod-library
pi@rpi3bplus-1:~$ gpioinfo
gpiochip0 - 54 lines:
line 0: unnamed unused input active-high
line 1: unnamed unused input active-high
line 2: unnamed unused input active-high
line 3: unnamed unused input active-high
line 4: unnamed unused input active-high
line 5: unnamed unused input active-high
line 6: unnamed unused input active-high
line 7: unnamed unused input active-high
line 8: unnamed unused input active-high
line 9: unnamed unused input active-high
line 10: unnamed unused input active-high
line 11: unnamed unused input active-high
line 12: unnamed unused input active-high
line 13: unnamed unused input active-high
line 14: unnamed unused input active-high
line 15: unnamed unused input active-high
line 16: unnamed unused input active-high
line 17: unnamed unused input active-high
line 18: unnamed unused input active-high
line 19: unnamed unused input active-high
line 20: unnamed unused input active-high
line 21: unnamed unused input active-high
line 22: unnamed unused input active-high
line 23: unnamed unused input active-high
line 24: unnamed "sysfs" input active-high [used]
line 25: unnamed unused input active-high
line 26: unnamed unused input active-high
line 27: unnamed unused input active-high
line 28: unnamed unused input active-high
line 29: unnamed "led0" output active-high [used]
line 30: unnamed unused input active-high
line 31: unnamed unused input active-high
line 32: unnamed unused input active-high
line 33: unnamed unused input active-high
line 34: unnamed unused input active-high
line 35: unnamed unused input active-high
line 36: unnamed unused input active-high
line 37: unnamed unused input active-high
line 38: unnamed unused input active-high
line 39: unnamed unused input active-high
line 40: unnamed unused input active-high
line 41: unnamed unused input active-high
line 42: unnamed unused input active-high
line 43: unnamed unused input active-high
line 44: unnamed unused input active-high
line 45: unnamed unused input active-high
line 46: unnamed unused input active-high
line 47: unnamed unused output active-high
line 48: unnamed unused input active-high
line 49: unnamed unused input active-high
line 50: unnamed unused input active-high
line 51: unnamed unused input active-high
line 52: unnamed unused input active-high
line 53: unnamed unused input active-high
gpiochip1 - 8 lines:
line 0: unnamed unused output active-high
line 1: unnamed unused output active-high
line 2: unnamed "led1" output active-low [used]
line 3: unnamed unused output active-high
line 4: unnamed unused input active-high
line 5: unnamed unused output active-high
line 6: unnamed unused output active-high
line 7: unnamed unused input active-high pi@rpi3bplus-1:~$
Note that chip0 line 24 shows "sysfs" -- since I exported it using sysfs commands.
From Python...
gpiozero library:
https://www.raspberrypi.org/documentation/usage/gpio/python/README.md
https://gpiozero.readthedocs.io/en/stable/
A newer Python binding (there is also a binding for gpiod -- I need to install that next). It is capable of using a number of low-level libraries
for actual GPIO access
RPi.GPIO:
Original Python GPIO library
pigpio:
Relies upon a daemon process with which client programs communicate to access GPIO
http://abyz.me.uk/rpi/pigpio/python.html
Adafruit Blinka:
An interface layer translating CircuitPython calls into R-Pi GPIO (or Beaglebone Black if one has one of those too). Adafruit is phasing out
usage of "native" libraries in example programs and device code in favor of using the CircuitPython GPIO operations.
https://learn.adafruit.com/adafruit-io-basics-digital-input/python-setup (a
bit out-of-date; they still refer to Debian "Stretch")
--
Wulfraed Dennis Lee Bieber AF6VN
wlfraed@ix.netcom.com http://wlfraed.microdiversity.freeddns.org/
--- SoupGate-Win32 v1.05
* Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3)