# 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="https://3732834919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrpyhVmLjv9Bu7tKDF8HF%2Fuploads%2F9aa2QkHLVfuHmj8xC5L7%2Fe_Chewie.png?alt=media&#x26;token=cd313c3e-bde1-402c-804b-9455b9ca44db" alt=""><figcaption><p>chewbacca</p></figcaption></figure> <figure><img src="https://3732834919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrpyhVmLjv9Bu7tKDF8HF%2Fuploads%2F0tlIN9BhZw8LiTCRKThs%2Fe_R2D2_Robot.png?alt=media&#x26;token=d3942800-ba9b-4057-9b06-c218c1f3391f" alt=""><figcaption><p>R2D2</p></figcaption></figure> <figure><img src="https://3732834919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrpyhVmLjv9Bu7tKDF8HF%2Fuploads%2FLzPFm2NvSSyQNAvR8oZs%2Fe_Zombie.png?alt=media&#x26;token=ec32960b-976c-4f0d-bef7-c6bba4ee1ed6" alt=""><figcaption><p>zombie</p></figcaption></figure></div>

{% file src="<https://3732834919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrpyhVmLjv9Bu7tKDF8HF%2Fuploads%2FhBi4Hmkp1Ns2OWFqi6b9%2Fchewy_roar.wav?alt=media&token=803b09b6-f46e-4848-ab7d-fb2f8f80427c>" %}

{% file src="<https://3732834919-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FrpyhVmLjv9Bu7tKDF8HF%2Fuploads%2FRJRXce3soOADsHVQkvSo%2FR2D2-yeah.wav?alt=media&token=01cb445a-6544-4ecf-badc-a766fc6c06ac>" %}

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