Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 8609

General programming discussion • Re: How to use "pinctrl poll" in bash script?

$
0
0
What about if there are more than only one sensors?
gpiomon can monitor more than one GPIO pin. You'll need to read the output of the command to see which GPIO was triggered.

Something like

Code:

#!/bin/bashGPIO_CHIP="gpiochip0"SWITCHPINS="17 18 19"EVENT="$(gpiomon --num-events=1 --format="%o %e" $GPIO_CHIP $SWITCHPINS)"echo "Event detected: $EVENT"
That will return something like "17 1" which will mean GPIO 17 has gone High. or maybe "18 0" to say GPIO 18 has gone low.
You can add a loop round that to keep polling.

Statistics: Posted by rpdom — Tue Feb 25, 2025 11:26 am



Viewing all articles
Browse latest Browse all 8609

Trending Articles