Subj : Re: how to write and read back GPIO pin states with lgpio To : josef@invalid.invalid From : Computer Nerd Kev Date : Mon Aug 05 2024 09:04:21 Josef M?llers wrote: > I used to use the sysfs interface to the GPIO pins (/sys/class/gpio) but > I understand that is deprecated nowadays. So I tried to switch to lgpio > which looks OK. Personally I switched to using the "gpio" command that's one of the example programs included with the bcm2835 library. If you're just trying to build C programs to replace the /sys/class/gpio devices in a shell script, it's an existing option. It does have some bugs though. https://www.airspayce.com/mikem/bcm2835/ See examples/gpio/gpio.c in the source code. > However, I have problems writing and reading back pin > states from different programs. > [snip] > However ... When I set the pin's state to "1", I still read back "0"! > > What am I doing wrong? Thanks in advance for any pointers. At a GUESS, you're reading the input buffer instead of the output buffer. In output mode the input is disabled and always reads zero or is meaningless. Unfortunately I've forgotten whether this is the case with the Pi, or at least where to look to confirm I'm not mis-remembering, so check for yourself. But this is a common way for IO hardware to work. -- __ __ #_ < |\| |< _# --- SoupGate-Win32 v1.05 * Origin: Agency HUB, Dunedin - New Zealand | Fido<>Usenet Gateway (3:770/3) .