# Compare Strength

**Programming Result**

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

**Introduction to HaloCode's motion sensor**

The motion sensor detects how HaloCode moves, including shaking strength.

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

**Set the range of shaking strength**

1\. Drag an Operators block () > () to the Scripts area, and change the value of the second parameter to "30". Add a Sensing block shaking strength to the first parameter.

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

2\. Add a Control block if () then ().

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

**Set LED animation**

3\. Add a Lighting block all LEDs light up (), and a Control block wait () seconds. Add another Lighting block light off all LEDs to light off all LEDs in 1 second.

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

4\. Likewise, for shaking strength greater than 60, we can duplicate the script. Change the value to 60 and LED color to red.

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

**Add event and control**

5\. Add an Events block when HaloCode is shaking and a Control block forever.

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

**Read shaking strength**

6\. Check the box for Sensing block shaking strength.

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

7\. Shake HaloCode! See if you can make the LED ring light up red.
