Last active
December 29, 2021 03:32
-
-
Save ma2shita/22d5161ee03da4971560bb96078a1596 to your computer and use it in GitHub Desktop.
Let's try IoT Prototyping / Fixed point camera with RPi (gpio6 / implementation)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
BCM_PIN=6 | |
trap 'exit 0' 1 2 3 15 | |
function _gpio_read() { | |
# $1 = reading GPIO pin (number of BMC pin) | |
raspi-gpio get $1 | awk -v RS=" " -F "=" -v k="level" '$1==k {print $2}' | |
} | |
raspi-gpio set $BCM_PIN ip pu | |
PREV=$(_gpio_read $BCM_PIN) | |
while true | |
do | |
CURR=$(_gpio_read $BCM_PIN) | |
if [ "$PREV" -ne "$CURR" ]; then | |
echo "Trigger on $0" | |
echo "Diff!: $PREV -> $CURR" | |
if [ "$CURR" -eq 0 ]; then | |
echo "shooting!" | nc localhost 19000 | |
fi | |
echo "$0 End." | |
fi | |
PREV=$CURR | |
sleep 0.1 | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
12/29/2021: Updating for using raspi-gpio from gpio(Wriring Pi). ref: https://qiita.com/ma2shita/items/b11045717333bcd79d15