# Emotion Detector

When a happy face is detected, the LED ring of HaloCode will light up, and make a smiling face.

![](/files/-LpgA28Lom7IqAUIDLt5)

**Add a sprite**

1\. Delete default sprite Panda

![](/files/-LpgA28MWNe87XY-qnO9)

2\. Add a new sprite, Empty button14

![](/files/-LpgA28NsUzWnKXl6IGs)

3\. Change the color, and size of the button.

![](/files/-LpgA28O3tL_oUj9swzJ)

4\. In the Blocks Area, click "+ extension" to add Cognitive Services (AI) blocks

![](/files/-LpgA28PEizXOWDbW9fJ)

5\. Drag an Events block when this sprite clicked to the Scripts Area. Add an AI block recognize emotion after (1) seconds

![](/files/-LpgA28QwDUIEjCcs84u)

6\. Add a Control block ig () then (), an AI block emotion is (happiness)?, and an Events block broadcast (). Create a new piece of message named "laugh"

![](/files/-LpgA28RqM5L3jKfDd8j)

7\. Check the box of AI block happiness value () to display the value on stage

![](/files/-LpgA28Sm5EfSKB_joSR)

**HaloCode makes a smiling face**

8\. Add an Events block 当when I receive (laugh), and a Lighting block show (). Draw a smiling face

![](/files/-LpgA28TeRUzDOXNFiB8)

9\. Add a Control block wait (2) seconds, and a Lighting block light off all LEDs

![](/files/-LpgA28UMtAT43dC13_S)


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://learn.pakronics.com.au/halocode-1/code-with-mu-a-simple-python-editor/examples/level-up/emotion-detector.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
