EasyManua.ls Logo

SunFounder PiDog - Page 68

Default Icon
109 pages
Print Icon
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Loading...
SunFounder PiDog Kit, Release 1.0
(continued from previous page)
current_coords = backward_coords
elif key == 'a':
current_coords = turn_left_coords
elif key == 'd':
current_coords = turn_right_coords
elif key == 'e':
current_coords = stand_coords
elif key == 'r':
current_pose['z'] += 1
if current_pose['z'] > 90:
current_pose['z'] = 90
elif key == 'f':
current_pose['z'] -= 1
if current_pose['z'] < 30:
current_pose['z'] = 30
if __name__ == "__main__":
try:
main()
except KeyboardInterrupt:
pass
finally:
t.join()
my_dog.close()
2.2.12 Play PiDog with Keyboard
In this example, we will use the keyboard to control PiDog. You can press these keys in the terminal to make it act.
Keys Function Keys Function
w forward s backward
a turn left d turn right
z lie down x stand up
c sit q bark
Q bark harder e pant
r wag tail t shake head
v stretch 1 doze off
2 push-up 3 howling
4 twist body 5 scratch
t handshake g high five
Run the Code
cd /home/pi/pidog/examples
sudo python3 py_11_keyboard_control.py
After the program runs, you will see a printed keyboard on the terminal. Now you can control PiDog with keyboard
in terminal.
Code
64 Chapter 2. Play with Python

Related product manuals