Do you ever feel down? From now on there will always be Misty to cheer you up!
In this project, Misty transforms into a motivational companion who delivers encouraging messages, delightful visuals, and engaging animations whenever her head is touched. This project uses Misty’s built-in features to create an uplifting interaction, making her the perfect source of inspiration and motivation.
from mistyPy.Robot import Robotfrom mistyPy.Events import Eventsimport randomimport timemisty =Robot("YOUR-ROBOT-IP-ADDRESS")misty.change_led(0, 0, 255)misty.move_head(0, 0, 0)misty.display_image("e_DefaultContent.jpg")defgoofy(): misty.play_audio("s_Awe2.wav") time.sleep(2) misty.display_image("e_JoyGoofy.jpg") misty.transition_led(0, 255, 0, 0, 0, 255, "breathe", 1200)# Transition from green to blue misty.move_arms(-40, 40)# Move left arm up, right arm down misty.move_head(-5, 0, 5)# Head tilt misty.speak("Keep going! You're doing great!")print("goofy")deflove(): misty.play_audio("s_Love.wav") time.sleep(2) misty.display_image("e_Love.jpg") misty.transition_led(255, 255, 0, 0, 255, 0, "breathe", 1200)# Transition from yellow to green misty.move_arms(20, -20)# Move right arm up, left arm down misty.move_head(0, 0, -5)# Nod head down misty.speak("Believe in yourself, you can achieve anything!")print("love")defjoy(): misty.play_audio("s_Joy.wav") time.sleep(2) misty.display_image("e_Joy.jpg") misty.transition_led(0, 0, 255, 255, 0, 0, "breathe", 1200)# Transition from blue to red misty.move_arms(-20, -20)# Both arms down misty.move_head(5, 5, 0)# Head nod to the side misty.speak("You’ve got this, keep pushing forward!")print("joy")defecstacy(): misty.play_audio("s_Ecstacy2.wav") time.sleep(2) misty.display_image("e_EcstacyHilarious.jpg") misty.transition_led(255, 0, 0, 255, 255, 0, "breathe", 1200)# Transition from red to yellow misty.move_arms(40, 40)# Both arms up misty.move_head(-10, 0, 0)# Shake head misty.speak("Every step you take is progress, don’t stop now!")print("ecstacy")defamazement(): misty.play_audio("s_Amazement.wav") time.sleep(2) misty.display_image("e_Amazement.jpg") misty.transition_led(255, 165, 0, 0, 255, 255, "breathe", 1200)# Transition from orange to cyan misty.move_arms(-40, 20)# Left arm down, right arm mid-level misty.move_head(0, -5, 5)# Slight tilt and nod misty.speak("Great things never come from comfort zones. Keep it up!")print("amazement")# Store animations in a listanimations = [goofy, love, joy, ecstacy, amazement]# Function to handle touch eventsdeftouched(data):print("Head touched!") random.choice(animations)()# Register touch eventmisty.register_event(event_name='touch', event_type=Events.TouchSensor, callback_function=touched, keep_alive=False)# Keep the program runningmisty.keep_alive()
After including the usual libraries, and setting up your Misty to default condition is time to create different Misty animations.
Each animation combines a unique blend of Misty's movements, LED colour transitions, audio clips, and expressive face displays, providing a variety of positive and engaging interactions.
Later all the different animations are stored in a list and with
random.choice(animations)()
you can select a random one.
The last lines of code enable Misty to listen to the TouchSensor Event, make sure to set keep_alive = False, in this way, Misty will react only once to your touch and will not be triggered several times, which would lead to mixed animations all at once.