EasyManua.ls Logo

SunFounder PiDog - Page 86

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
"wag_tail"
step_count : How many times to perform this action.
speed : How fast to perform the action.
Here is an example of usage:
1. Do ten push-ups, then sit on the floor and act cute.
from pidog import Pidog
import time
my_dog = Pidog()
try:
# pushup
my_dog.do_action("half_sit", speed=60)
my_dog.do_action("pushup", step_count=10, speed=60)
my_dog.wait_all_done()
# act cute
my_dog.do_action("sit", speed=60)
my_dog.do_action("wag_tail", step_count=100,speed=90)
my_dog.do_action("tilting_head", step_count=5, speed=20)
my_dog.wait_head_done()
my_dog.stop_and_lie()
except KeyboardInterrupt:
pass
except Exception as e:
print(f"\033[31mERROR: {e}\033[m")
finally:
print("closing ...")
my_dog.close()
2.3.7 PiDog Speak
PiDog can make sound, it is actually playing a piece of audio.
These audios are saved under pidog\sounds path, you can call the following function to play them.
Pidog.speak(name)
name : Filename (without suffix), such as "angry". PiDog provides the following audio.
"angry"
"confused_1"
"confused_2"
"confused_3"
"growl_1"
"growl_2"
"howling"
"pant"
82 Chapter 2. Play with Python

Related product manuals