Compare commits
2 Commits
625f77cdce
...
1ab2d103ec
Author | SHA1 | Date |
---|---|---|
|
1ab2d103ec | 2 weeks ago |
|
a55a88f6f5 | 2 weeks ago |
1 changed files with 43 additions and 2 deletions
@ -1,24 +1,65 @@ |
|||
#! /usr/bin/bash |
|||
|
|||
pin_rot=17 # z.B. Pin 11 (BCM 17) |
|||
pin_gelb=27 # z.B. Pin 13 (BCM 27) |
|||
pin_gruen=22 # z.B. Pin 15 (BCM 22) |
|||
|
|||
state_rot=0 |
|||
state_gelb=0 |
|||
state_gruen=0 |
|||
|
|||
gpiochip="gpiochip0" |
|||
|
|||
function resetPins() { |
|||
echo "Ampel aus" |
|||
gpioset "${gpiochip}" ${pin_rot}=0 ${pin_gelb}=0 ${pin_gruen}=0 |
|||
} |
|||
|
|||
|
|||
function setPins() { |
|||
gpioset "${gpiochip}" ${pin_rot}=${state_rot} ${pin_gelb}=${state_gelb} ${pin_gruen}=${state_gruen} |
|||
} |
|||
|
|||
function ampel() { |
|||
case ${1} in |
|||
1) |
|||
echo "Ampelphase rot" |
|||
state_rot=1 |
|||
state_gelb=0 |
|||
state_gruen=0 |
|||
setPins |
|||
sleep 5 |
|||
;; |
|||
2) |
|||
echo "Ampelphase rot/gelb" |
|||
state_rot=1 |
|||
state_gelb=1 |
|||
state_gruen=0 |
|||
setPins |
|||
sleep 1 |
|||
;; |
|||
3) |
|||
echo "Ampelphase grün" |
|||
state_rot=0 |
|||
state_gelb=0 |
|||
state_gruen=1 |
|||
setPins |
|||
sleep 3 |
|||
;; |
|||
4) |
|||
echo "Ampelphase gelb" |
|||
state_rot=0 |
|||
state_gelb=1 |
|||
state_gruen=0 |
|||
setPins |
|||
sleep 2 |
|||
;; |
|||
esac |
|||
} |
|||
|
|||
for i in 1 2 3 4; do |
|||
ampel "${i}" |
|||
for phase in 1 2 3 4 1; do |
|||
ampel "${phase}" |
|||
done |
|||
|
|||
resetPins |
|||
|
|||
|
Loading…
Reference in new issue