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

Who for Halloween

Misty plays different Halloween characters and you can choose your favourite!

Misty will start selecting a random character after listening to her keyword.

You can interact with her by asking something like: "Hey Misty, what are you going to dress up as for Halloween?"

And after an evil laugh she'll randomly select one of her uploaded characters: R2D2, Chewbacca or Zombie!

from mistyPy.Robot import Robot
from mistyPy.Events import Events
import random
import time

misty = Robot("YOUR-ROBOT-IP-ADDRESS")
misty.change_led(0, 255, 0)
misty.move_head(0, 0, 0)
misty.move_arms(20, 20)

# Define the playCharacter function in Python
def playCharacter(characterName):
    if characterName == "R2D2":
        # R2D2 character with specific movements and sounds
        misty.change_led(0, 0, 255)  # Blue LED
        misty.display_image("e_R2D2_Robot.png")
        time.sleep(0.5)
        misty.play_audio("R2D2-yeah.wav")
        i = 0
        while i < 3:
            misty.change_led(255, 255, 255)  # White LED
            misty.drive_time(1, -70, 500)
            time.sleep(0.6)
            misty.change_led(0, 0, 255)  # Blue LED
            misty.drive_time(-1, 70, 500)
            time.sleep(0.6)
            i = i + 1    
        time.sleep(0.5)
        misty.play_audio("R2D2-yeah.wav")  # Play sound again

    elif characterName == "Chewbacca":
        # Chewbacca character with sound and arm movement
        misty.display_image("e_Chewie.png")
        misty.change_led(128, 64, 0)  # Brown LED
        time.sleep(0.5)
        misty.play_audio("chewy_roar.wav")
        misty.move_arms(-25, -25)
        misty.move_head(-25, -2, 0)
        time.sleep(0.2)
        misty.play_audio("chewy_roar.wav")  # Play again at high volume

    elif characterName == "Zombie":
        # Zombie character with sound and arm movement
        misty.change_led(128, 128, 0)  # Sickly green LED
        misty.display_image("e_Zombie.png")
        time.sleep(0.5)
        misty.play_audio("s_Fear.wav")
        misty.move_arms(0, 0)  # Arms out straight
        misty.move_head(-20, -5, 0)
        time.sleep(0.2)
        
        misty.move_arms(-15, 18)  # Right arm up, left down
        misty.move_head(-20, 2, 0)
        time.sleep(0.2)
        
        misty.move_arms(10, -18)  # Left arm up, right down
        misty.move_head(-20, -5, 0)
        time.sleep(0.2)
        misty.play_audio("s_Fear.wav")  # Play sound again

# Store animations in a list
characters = ["R2D2", "Chewbacca", "Zombie"]

# Function to handle touch events
def Key_Phrase_Recognized(data):
    misty.display_image("e_JoyGoofy2.jpg")
    misty.speak("Sure, here is one of my many characters! I hope you'll enjoy it and don't get too scared")
    time.sleep(5)
    misty.display_image("e_Rage4.jpg")
    misty.play_audio("s_PhraseEvilAhHa.wav")
    time.sleep(3)
    playCharacter(random.choice(characters))

# Register touch event
misty.register_event(event_name='KPR_event', event_type=Events.KeyPhraseRecognized, callback_function=Key_Phrase_Recognized, keep_alive=True)
# Keep the program running
misty.keep_alive()

You can also choose to play one of your characters using this format:

playCharacter("your-character's-name")

Don't forget to upload these files in your Misty to get amazing results!

Last updated 6 months ago

🎃
115KB
chewy_roar.wav
26KB
R2D2-yeah.wav
chewbacca
R2D2
zombie