EasyManua.ls Logo

SunFounder PiCrawler Kit - Sound Effect

Default Icon
137 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 PiCrawler Kit
(continued from previous page)
if __name__ == "__main__":
main()
How it works?
PiCrawler should take appropriate action based on the keyboard characters read. The lower() function converts
upper case characters into lower case characters, so that the letter remains valid regardless of case.
while True:
key = readchar.readkey()
key = key.lower()
if key in('wsad'):
if 'w' == key:
crawler.do_action('forward',1,speed)
elif 's' == key:
crawler.do_action('backward',1,speed)
elif 'a' == key:
crawler.do_action('turn left',1,speed)
elif 'd' == key:
crawler.do_action('turn right',1,speed)
sleep(0.05)
show_info()
elif key == readchar.key.CTRL_C or key in readchar.key.ESCAPE_SEQUENCES:
print("\n Quit")
break
3.5 Sound Effect
In this example, we use PiCrawler’s (to be precise, Robot HAT’s) sound effects. It consists of three parts, namely
Muisc, Sound, Text to Speech.
50 Chapter 3. Play with Python

Other manuals for SunFounder PiCrawler Kit

Related product manuals