forked from wuxx/RPI-HAT-Programmer
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.sh
More file actions
executable file
·50 lines (38 loc) · 860 Bytes
/
test.sh
File metadata and controls
executable file
·50 lines (38 loc) · 860 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/bash
BUZZER_GPIO=4
LED_GPIO=2
KEY_GPIO=3
gpio mode $BUZZER_GPIO out
gpio mode $LED_GPIO out
gpio mode $KEY_GPIO in
trap 'onCtrlC' INT
function onCtrlC () {
echo 'exit'
exit 0
}
echo "==== buzzer test ===="
for((i=0;i<5;i++)); do
gpio write $BUZZER_GPIO 1
sleep 0.5
gpio write $BUZZER_GPIO 0
sleep 0.5
done
echo "==== led test ===="
for((i=0;i<5;i++)); do
gpio write $LED_GPIO 1
sleep 0.5
gpio write $LED_GPIO 0
sleep 0.5
done
echo "==== key test ===="
echo "please press the button... input Ctrl-C to exit."
LAST_KEY_VALUE=$(gpio read $KEY_GPIO)
CURR_KEY_VALUE=$LAST_KEY_VALUE
while [ 1 ]; do
CURR_KEY_VALUE=$(gpio read $KEY_GPIO)
if [ ${CURR_KEY_VALUE} != ${LAST_KEY_VALUE} ]; then
echo "key value: ${CURR_KEY_VALUE}"
LAST_KEY_VALUE=$CURR_KEY_VALUE
fi
done
exit 0