Quantcast
Viewing all articles
Browse latest Browse all 5402

Beginners • Re: Control GPIO with shell

Use the libgpiod tools - they work on any Linux platform. You can find them in the gpiod apt package.

The apt packages are currently the libgpiod v1 tools that require you to specify the gpiochip to use.
e.g. setting GPIO4 high:

Code:

gpioset 0 4=1
where the 0 indicates /dev/gpiochip0.

The libgpiod v2 tools allow you to set the line by name, but as they aren't available in apt yet you need to build them yourself from source.

e.g.

Code:

gpioset -t0 GPIO4=1
where the -t0 is to get gpioset to immediately exit after setting the line value as on most platforms the device driver may reset the line to its default state when the line is released by gpioset (which could be considered a fail-safe). That isn't the case on the Pi - the device driver persists the value of output lines when the line is released so it behaves more like the deprecated GPIO sysfs interface.

Statistics: Posted by warthog618 — Sun Sep 01, 2024 11:57 pm



Viewing all articles
Browse latest Browse all 5402

Trending Articles