# Emotion Detector

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28Lom7IqAUIDLt5%2F0.png?generation=1569477899257082\&alt=media)

**Add a sprite**

1\. Delete default sprite Panda

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28MWNe87XY-qnO9%2F1.gif?generation=1569477899378016\&alt=media)

2\. Add a new sprite, Empty button14

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28NsUzWnKXl6IGs%2F2.gif?generation=1569477899343470\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28O3tL_oUj9swzJ%2F3.gif?generation=1569477899352577\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28PEizXOWDbW9fJ%2F4.gif?generation=1569477899339807\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28QwDUIEjCcs84u%2F5.gif?generation=1569477899313252\&alt=media)

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"

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28RqM5L3jKfDd8j%2F6.gif?generation=1569477899378127\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28Sm5EfSKB_joSR%2F7.gif?generation=1569477899318737\&alt=media)

**HaloCode makes a smiling face**

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28TeRUzDOXNFiB8%2F8.gif?generation=1569477899305301\&alt=media)

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

![](https://2169521322-files.gitbook.io/~/files/v0/b/gitbook-legacy-files/o/assets%2Fpakronics-education%2F-Lpg0r0jyU3XQdgAmqp8%2F-LpgA28UMtAT43dC13_S%2F9.gif?generation=1569477899349364\&alt=media)
