
SunFounder pisloth
(continued from previous page)
sloth
.
set_offset([
0
,
0
,
0
,
0
])
def
main
():
music
.
background_music(
'./musics/india-Arulo.mp3'
)
music
.
music_set_volume(
20
)
sloth
.
do_action(
'stomp left'
,
3
,bpm
=
129
)
sloth
.
do_action(
'stomp right'
,
3
,bpm
=
129
)
sloth
.
do_action(
'moon walk left'
,
3
,bpm
=
129
)
sloth
.
do_action(
'moon walk right'
,
3
,bpm
=
129
)
for
i
in
range
(
3
):
sloth
.
do_action(
'swing'
,
1
,bpm
=
129
)
sloth
.
do_action(
'stand'
,
1
,bpm
=
129
)
for
i
in
range
(
3
):
sloth
.
do_action(
'close'
,
1
,bpm
=
129
)
sloth
.
do_action(
'stand'
,
1
,bpm
=
129
)
sloth
.
do_action(
'open'
,
1
,bpm
=
129
)
sloth
.
do_action(
'stand'
,
1
,bpm
=
129
)
sloth
.
do_action(
'tiptoe left'
,
2
,bpm
=
129
)
sloth
.
do_action(
'tiptoe right'
,
2
,bpm
=
129
)
sloth
.
do_action(
'stomp left'
,
3
,bpm
=
129
)
sloth
.
do_action(
'stomp rihgt'
,
3
,bpm
=
129
)
sloth
.
do_action(
'moon walk left'
,
3
,bpm
=
129
)
sloth
.
do_action(
'moon walk right'
,
3
,bpm
=
129
)
for
i
in
range
(
3
):
sloth
.
do_action(
'hook'
,
1
,bpm
=
129
)
sloth
.
do_action(
'stand'
,
1
,bpm
=
129
)
for
i
in
range
(
4
):
sloth
.
do_action(
'swing'
,
1
,bpm
=
129
)
sloth
.
do_action(
'big swing'
,
1
,bpm
=
129
)
sloth
.
do_action(
'swing'
,
1
,bpm
=
129
)
sloth
.
do_action(
'stand'
,
1
,bpm
=
129
)
sloth
.
do_action(
'tiptoe right'
,
2
,bpm
=
129
)
sloth
.
do_action(
'stand'
,
2
,bpm
=
129
)
music
.
music_stop()
time
.
sleep(
10
)
if
__name__
==
"__main__"
:
while
True
:
main()
How it works?
You can make PiSloth play music by importing the following libraries.
from
robot_hat
import
TTS, Music
Play the background music in the
pisloth/examples/musics
directory and set the volume to 20. You can also
add music to the
musics
folder via
64
Chapter 4. Play with Python
Summary of Contents for PiSloth
Page 1: ...SunFounder pisloth www sunfounder com Oct 19 2021 ...
Page 2: ......
Page 4: ...ii ...
Page 6: ...SunFounder pisloth 2 CONTENTS ...
Page 8: ...SunFounder pisloth 4 Chapter 1 Component List and Assembly Instructions ...
Page 18: ...SunFounder pisloth EXAMPLE 14 Chapter 3 Play with Ezblock ...
Page 20: ...SunFounder pisloth 16 Chapter 3 Play with Ezblock ...
Page 22: ...SunFounder pisloth Confuse Happy 18 Chapter 3 Play with Ezblock ...
Page 23: ...SunFounder pisloth Fear Sad 3 5 Emotional PiSloth 19 ...
Page 25: ...SunFounder pisloth 3 6 Dance Now PiSltoh will show you his newly learned dance 3 6 Dance 21 ...
Page 28: ...SunFounder pisloth 24 Chapter 3 Play with Ezblock ...
Page 32: ...SunFounder pisloth 28 Chapter 3 Play with Ezblock ...
Page 35: ...SunFounder pisloth 3 8 Remote Control 31 ...
Page 39: ...SunFounder pisloth 3 9 Custom Step 35 ...
Page 41: ...SunFounder pisloth The complete code is as follows 3 9 Custom Step 37 ...
Page 50: ...SunFounder pisloth Step 7 Click the WRITE button 46 Chapter 4 Play with Python ...
Page 86: ...SunFounder pisloth 82 Chapter 4 Play with Python ...
Page 90: ...SunFounder pisloth Yes then Ok Finish 86 Chapter 5 Appendix ...
Page 94: ...SunFounder pisloth Step 4 Double click the connection just created 90 Chapter 5 Appendix ...
Page 102: ...SunFounder pisloth 98 Chapter 5 Appendix ...