Welcome to Tiny:bit Pro repository
6.14 Frog beating
This course is mainly based on the accelerometer that comes with micro:bit.
When we rotate the micro:bit around the x-axis, that is, when rotating on the yoz plane, the degree of the rotation (picth) will be changed.
When we rotate the micro:bit around the y-axis, that is, when rotating on the xoz plane, the degree of the rotation (roll) will be changed.
When we rotate the micro:bit around the z-axis, that is, when rotating on the yoz plane, the degree of the rotation (yaw) will be changed.
In this experiment, we use the rotation angle to judge.
Programming method:
Mode 1 online programming: First, we need to connect the micro:bit to the computer by USB cable. The computer will pop up a USB flash drive and click on the URL in the USB flash drive: http://microbit.org/ to enter the programming interface. Add the Yahboom package: https://github.com/YahboomTechnology/Tiny-bitLib to program.
Mode 2 offline programming: We need to open the offline programming software. After the installation is complete, enter the programming interface, click【New Project】, add Yahboom package: https://github.com/YahboomTechnology/Tiny-bitLib, you can program.
In the picture shown below, the ultrasonic module with red wire frame.
2.Learning goal
2-1. Learn how to use accelerometer graphically program building blocks
2-2.The function is realized by programming: when we gently press the tail of the robot car with our hand, the Tiny-bit will make a sound and advance a short distance.
3.Search for block
The following is the location of the building blocks required for this programming.







4.Combine block
The summary program is shown below:

5.Experimental phenomena
After the program download is complete, open the power of the robot car. When we gently press the tail of the Tiny-bit, the forward arrow will be displayed on the micro:bit dot matrix, and a piece of music will be played, and the lights will be randomly lit at the same time, the car advances for a short time, then stops.
As shown below.
