The button of the pico in python?

Hi,
I am not very experienced with Raspberry Pi(co) nor Python. I was given
a R-Pico and enjoy learning about Python (as a former C-Programmer).
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?
Or do I think the wrong way?
I have a mad and funny idea which I will publish here ... :-D
FW
Reply to
F. W.
Loading thread data ...
Have yo been here:
formatting link

and downloaded the PICO documentation?
I'd imagine that's covered in the docs, which are generally pretty good. Same goes for the RPi range, though for that having a link to the Debian documentation may also help:
formatting link

--
Martin    | martin at 
Gregorie  | gregorie dot org
Reply to
Martin Gregorie
Am 23.06.2021 um 09:01 schrieb Martin Gregorie:
Yes, thank you again.
The button is not mentioned. So I think it is not "reachable".
:-(
FW
Reply to
F. W.
It is mentioned though, depending on which document you read. In the Pico datasheet for example, it is explained that the "bootsel" button is connected to "TP6" (test point 6) which is *not* a GPIO pin. It can only be used to select USB boot at power-up. Its status cannot be read. So yes: not reachable.
Reply to
A. Dumas
Download the book for an introduction to hardware things like buttons:
formatting link
(free pdf link from there, or buy a printed version)
Reply to
A. Dumas
On Wed, 23 Jun 2021 08:27:18 +0200, "F. W." declaimed the following:
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)
formatting link

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.
formatting link
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:
formatting link
formatting link
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
formatting link

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.
formatting link
(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/
Reply to
Dennis Lee Bieber
Dana Wed, 23 Jun 2021 12:14:14 -0400, Dennis Lee Bieber napis'o:
[snip]
he asked about pico.
Reply to
Nikolaj Lazic

ElectronDepot website is not affiliated with any of the manufacturers or service providers discussed here. All logos and trade names are the property of their respective owners.