> For the complete documentation index, see [llms.txt](https://lessons.mistyrobotics.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://lessons.mistyrobotics.com/python-projects/who-for-halloween.md).

# Who for Halloween

Misty will start selecting a random character after listening to her keyword.&#x20;

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

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

```python
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")`

<div><figure><img src="/files/VaQtIELPT7LQXj1OYsGu" alt=""><figcaption><p>chewbacca</p></figcaption></figure> <figure><img src="/files/L9d2fwJL6RBfw8w5n8G5" alt=""><figcaption><p>R2D2</p></figcaption></figure> <figure><img src="/files/9An9tKOHKGCrfDpoQLoe" alt=""><figcaption><p>zombie</p></figcaption></figure></div>

{% file src="/files/UGc9nxUgJYyUB3J0ynK6" %}

{% file src="/files/XsZGj5k2EmXK8Jt6nSS5" %}

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