This is my first post here and I am not an expert of Linux /Bash scripting yet. :-)
So I wrote the following code for my Raspberry Pi and it works fine except for one small issue.
I am using SSH to log into the raspberry Pi.When pin 17 is high, ( digital logic value of 1 aka 5 volts ), I want the message “I noticed a 1” printed on the terminal output and then I want to exit the script and still stay logged into the raspberry Pi.
The problem that I am facing is when the script sees a logic value of 1, it shuts down the entire ssh connection adn takes me back to my laptop's terminal session.
I dont want the script to exit the ssh connection when pin 17 reads a 1. I just want it to stop executing the scriot and take me back to the raspberry Pi terminal where I am still logged into the raspberry Pi so that I can do other stuff.
I basically DO NOT want to close the SSH session when the scipt exits. Could you please give me some suggestions to fix this issue?
Thank you for the reply!
pin=17
gpio mode $pin in
while true; do
if [[ $(gpio read $pin) -eq 1 ]]; then
echo "I noticed a 1 whcih means I noticed 5 volts!"
return
elif [[ $(gpio read $pin) -eq 0 ]]; then
echo "Did not see a 1, so I will keep looping"
echo ""
sleep 2
fi
done