EasyManua.ls Logo

SunFounder PiSloth - Page 86

SunFounder PiSloth
113 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 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 Filezilla Software.
82 Chapter 4. Play with Python

Related product manuals