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

Automation, sensing and robotics • Re: Help - GPIO Wiring & Script for Float Switch

$
0
0
Thank you to everyone for your feedback. The links shared here have offered a great starting point for my learning and to get at the result I've been seeking. I started tinkering with python scripts, but then discovered pinctrl and it allowed me to do exactly what I wanted in a bash script. I've included my script below in case it is useful for someone else in the future.

Code:

pinctrl set 16 puif [[ $(pinctrl get 16 | grep 'hi') == *hi* ]]; then  echo "pin is high - circuit open - tank full"  echo "Full" > /var/www/html/water_level.txtelif [[ $(pinctrl get 16 | grep 'lo') == *lo* ]]; then  echo "pin is low - circuit closed - tank low"  echo "Low" > /var/www/html/water_level.txtelse  pinctrl get 16  echo "Error" > /var/www/html/water_level.txtfi

Statistics: Posted by craftycraft — Fri Mar 29, 2024 12:42 am



Viewing all articles
Browse latest Browse all 5070

Trending Articles