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:
(f
"
\033
[31mERROR: {e}
\033
[m"
)
finally
:
(
"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
Summary of Contents for PiDog
Page 1: ...SunFounder PiDog Kit Release 1 0 sunfounder Jan 09 2023 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder PiDog Kit Release 1 0 Content 2 CONTENTS ...
Page 8: ...SunFounder PiDog Kit Release 1 0 4 Chapter 1 Component List and Assembly Instructions ...
Page 15: ...SunFounder PiDog Kit Release 1 0 Step 7 Click the WRITE button 2 1 Quick Guide on Python 11 ...
Page 92: ...SunFounder PiDog Kit Release 1 0 88 Chapter 2 Play with Python ...
Page 108: ...SunFounder PiDog Kit Release 1 0 104 Chapter 4 Appendix ...