]>
totsipaki.net Git - Scripts.git/blob - education/robotics/wedo.sh
2 #script για τον έλεγχο του κινητήρα του wedo 2.0
3 #Copyright Parafestas Nikos 2025 totsipaki.net
5 #This program is free software: you can redistribute it and/or modify
6 #it under the terms of the GNU General Public License as published by
7 #the Free Software Foundation, either version 3 of the License, or
8 #(at your option) any later version.
10 #This program is distributed in the hope that it will be useful,
11 #but WITHOUT ANY WARRANTY; without even the implied warranty of
12 #MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 #GNU General Public License for more details.
15 #You should have received a copy of the GNU General Public License
16 #along with this program. If not, see <http://www.gnu.org/licenses/>.
18 WEDO_MAC
="XX:XX:XX:XX:XX:XX" #find it with bluetoothctl --> scan on --> devices
22 # Συνάρτηση καθαρισμού
25 if [ -n "$MOTOR_PID" ]; then
26 kill $MOTOR_PID 2>/dev
/null
28 echo -e "\nΤερματισμός προγράμματος..."
36 gatttool
-b "$WEDO_MAC" --char-write-req -a "$HANDLE" -n 01010100 >/dev
/null
2>&1
37 echo "Ο κινητήρας σταμάτησε"
42 gatttool
-b "$WEDO_MAC" --char-write-req -a "$HANDLE" -n 010101$1 >/dev
/null
2>&1
43 sleep $KEEP_ALIVE_INTERVAL
49 echo "========================================"
50 echo " Έλεγχος Κινητήρα LEGO WeDo 2.0"
51 echo "========================================"
52 echo -e "Χρησιμοποιήστε:\n -> Δεξί Βέλος: Κίνηση Εμπρός\n <- Αριστερό Βέλος: Κίνηση Πίσω\n X: Διακοπή κινητήρα\n Ctrl+C: Έξοδος\n"
57 if [[ $key == $
'\x1b' ]]; then
64 [[ $key == "x" ]] && echo "stop" ||
echo ""
72 [ -n "$MOTOR_PID" ] && kill $MOTOR_PID 2>/dev
/null
78 [ -n "$MOTOR_PID" ] && kill $MOTOR_PID 2>/dev
/null
85 [ -n "$MOTOR_PID" ] && kill $MOTOR_PID 2>/dev
/null