Compare Strength

 

Programming Result

1.gif

 

Introduction to Halocode's motion sensor

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

2.png

 

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.

3.gif

 

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

4.gif

 

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.

5.gif

 

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

6.gif

 

Add event and control

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

7.gif

 

Read shaking strength

6. Check the box for Sensing block shaking strength.

8.gif

 

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

Download code


Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.