> For the complete documentation index, see [llms.txt](https://learn.pakronics.com.au/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://learn.pakronics.com.au/halocode-1/code-with-mu-a-simple-python-editor/examples/level-up/emotion-detector.md).

# 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)
