Misty Lessons
  • Misty Lessons
    • ๐Ÿ“–Welcome to Misty Lessons
    • ๐Ÿ“šGet to know your Misty
    • ๐Ÿ“ฒConnect to Misty
    • ๐Ÿ‘ฉโ€๐Ÿ’ปMisty Studio
    • ๐Ÿ–ฅ๏ธDesktop Environment
    • โฌ†๏ธUpdate your Misty
    • ๐Ÿ‘ฅProjects
  • Blockly
    • ๐ŸงฉBlockly Lessons
      • ๐ŸคธLesson 1: Movement
      • ๐ŸŽถLesson 2: Voice and Sound
      • ๐ŸŽญLesson 3: Expressions
      • ๐ŸŽฅLesson 4: Robot Cinema
      • ๐Ÿ› ๏ธLesson 5: Events
      • โ˜บ๏ธLesson 6: Face recognition
      • ๐Ÿ”ขLesson 7: Variables and Functions
      • ๐Ÿ’ฌLesson 8: NLP
    • ๐ŸซBlockly projects
  • Blockly Elements
    • โš›๏ธMisty Blocks
      • Movement
      • Speech
      • Audio
      • Vision
      • Events
      • Miscellaneous
      • NLP
      • System
    • ๐Ÿ”Basic Blocks
      • Logic
      • Loops
      • Math
      • Text
      • Lists
    • ๐Ÿ…ฐ๏ธAdvanced Blocks
      • Variables
      • Functions
  • Python
    • ๐ŸPython Lessons
      • ๐ŸฆฟLesson 1: Loco-motion
      • ๐Ÿค–Lesson 2 : Build a character
      • ๐Ÿง Lesson 3: Create memories
      • โš’๏ธLesson 4: Event skills
      • ๐Ÿ‘€Lesson 5: Expand awareness
      • ๐Ÿ”—Lesson 6: Compact code
      • ๐Ÿ—ฃ๏ธLesson 7: Start a conversation
  • Python Elements
    • ๐ŸธMisty Python API
      • Motion and Mobility
      • Display and LED
      • Record Assets
      • Change/Remove Assets
      • Stream Assets
      • Get Assets
      • Events
      • Sensor Events
      • Speech and NLP
      • Arduino Backpack
      • System
      • Slam
    • ๐Ÿ“—Python Definitions
  • Python Projects
    • ๐Ÿ”ฎMistyGPT
    • ๐ŸšจMisty Intruder Alert
    • ๐Ÿ“บConference Assistant
    • ๐Ÿท๏ธQR code detector
    • ๐Ÿ•ต๏ธโ€โ™‚๏ธMisty follow human
    • ๐Ÿ‘‹Misty wave back
    • ๐Ÿ–ฒ๏ธMisty OA
    • ๐ŸŒGet weather
    • ๐ŸššMisty Delivery
    • ๐Ÿซ‚Motivational Misty
    • ๐Ÿ–ผ๏ธMisty Museum Guide
    • ๐ŸŽƒWho for Halloween
  • ARDUINO
    • โ™พ๏ธArduino Backpack
    • ๐ŸฆŽArduino
    • ๐Ÿ”งArduino Lessons
      • ๐Ÿ”ŒArduino to Misty
      • โž•Misty to Arduino
  • ARDUINO PROJECTS
    • ๐Ÿ› ๏ธMisty Tracker
    • ๐ŸฆพMisty Arm
  • Community Projects
    • ๐ŸŒค๏ธMisty weather forecaster
  • HARDWARE EXTENSION
    • โš™๏ธArduino breadboard support
    • ๐ŸฆพMisty arm
    • ๐ŸฅคTin holder
  • Resource Database
    • ๐Ÿ“Image files
    • ๐Ÿ“Audio files
    • ๐Ÿ“Languages
    • ๐Ÿ“Known objects
    • ๐Ÿ“NLP Actions
    • ๐Ÿ“Action Commands
    • ๐Ÿ“ChatGPT PDF files
    • ๐Ÿ“AR Tag Dictionary
    • โš™๏ธTechnical Specifications
Powered by GitBook
On this page
  1. Python Projects

Motivational Misty

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 Robot
from mistyPy.Events import Events
import random
import time

misty = Robot("YOUR-ROBOT-IP-ADDRESS")
misty.change_led(0, 0, 255)
misty.move_head(0, 0, 0)
misty.display_image("e_DefaultContent.jpg")

def goofy():
    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")

def love():
    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")

def joy():
    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")

def ecstacy():
    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")

def amazement():
    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 list
animations = [goofy, love, joy, ecstacy, amazement]

# Function to handle touch events
def touched(data):
    print("Head touched!")
    random.choice(animations)()

# Register touch event
misty.register_event(event_name='touch', event_type=Events.TouchSensor, callback_function=touched, keep_alive=False)

# Keep the program running
misty.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.

Last updated 6 months ago

๐Ÿซ‚