from microbit import *
import speech
def on_button_pressed_a():
#Show image for beating heart
display.show(Image("00900:09990:99999:99999:09090"))
sleep(1000)
display.show(Image("00000:00900:09990:09090:00000"))
sleep(1000)
display.show(Image("09990:90009:00000:09090:00000"))
sleep(1000)
display.show(Image("00900:09090:00000:09090:00000"))
sleep(1000)
#Rotate Left Arm with Servo and Left Eye with Led
for index in range(4):
for index1 in range(2):
pin1.write_analog(180)
sleep(1000)
pin1.write_digital(0)
sleep(1000)
if index == 0:
# Robot Chase said, "My name is Chase."
speech.pronounce("mahahihih nehehihihm ihihss CHEHEHIHIHS.", speed=92, pitch=60, throat=190, mouth=190)
sleep(1000)
if index == 1:
# Robot Chase said, "What is your name?"
speech.pronounce("Woh5oh3t ihihs yohohohr neh2eh3ih4ih8m", speed=92, pitch=60, throat=190, mouth=190)
sleep(1500)
if index == 2:
# Robot Chase said, "Nice to meet you."
speech.pronounce("Nahahihihs tuhuh mihiht yuhuh.", speed=92, pitch=60, throat=190, mouth=190)
sleep(1000)
def on_button_pressed_b():
#Show image for beating heart
display.show(Image("00900:09990:99999:99999:09090"))
sleep(1000)
display.show(Image("00000:00900:09990:09090:00000"))
sleep(1000)
display.show(Image("09990:90009:00000:09090:00000"))
sleep(1000)
display.show(Image("00900:09090:00000:09090:00000"))
sleep(1000)
#Rotate Right Arm with Servo and Right Eye with Led
for index in range(5):
for index1 in range(2):
pin2.write_analog(180)
sleep(1000)
pin2.write_digital(0)
sleep(1000)
if index == 0:
# Robot Chase said, "What are you doing now?"
speech.pronounce("Woh5oh3t ahahr yuhuh duhuhihihnx nnahah3uh5uh8", speed=92, pitch=60, throat=190, mouth=190)
sleep(1000)
if index == 1:
# Robot Chase said, "Let's play with me."
speech.say("Let's play with me.", speed=92, pitch=60, throat=190, mouth=190)
sleep(1500)
if index == 2:
# Robot Chase said, "I am a micro-bit Robot."
speech.say("I am a micro-bit Robot.", speed=92, pitch=60, throat=190, mouth=190)
sleep(1000)
if index == 3:
# Robot Chase said, "I am created by my creators to accompany you to play. I hope you love me."
speech.say("I am created by my creators to accompany you to play.", speed=92, pitch=60, throat=190, mouth=190)
sleep(500)
speech.say("I hope you love me.", speed=92, pitch=60, throat=190, mouth=190)
sleep(1000)
pin1.write_digital(0)
#Function calling when either Button A or Button B is pressed.
while 1:
if button_a.is_pressed(): on_button_pressed_a()
elif button_b.is_pressed(): on_button_pressed_b()
No comments:
Post a Comment
Please kindly give nice comment that can improve our website in the future.
Thank you.
Regards,
3DPC-DIY4 Pro