Robot Kit for Micro:bit Tutorial: 6.13 Spinning top
This course mainly uses the accelerometer that comes with micro:bit. When I hold the Tiny-bit and move it, the values of X, Y and Z in the three directions of acceleration will change.
In this experiment, we use the data be changed in the X direction.
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/lzty634158/Tiny-bit 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/lzty634158/Tiny-bit, you can program.
In the picture shown below, the ultrasonic module with red wire frame.
2-1. Learn how to use compass graphically program building blocks
2-2. The function is realized by programming: When we tilt the Tiny-bit by hand, measuring the magnitude of the data is changed in the x-axis direction of the accelerometer, and set the time of the Tiny-bit rotation based on this data.
3.Search for block
The following is the location of the building blocks required for this programming.
The summary program is shown below:
After the program is downloaded, open the power of robot car, and micro:bit dot matrix will display a heart.
When we press the A button, an arrow pointing to the B button will appear as shown in Figure 1. Then we can shake Tiny-bit. We can see that the micro:bit dot matrix will display data of the x-axis will changed of the accelerometer , as shown in Figure 2 below.
Next, we need to put the Tiny-bit on the ground or on the desktop. After pressing the B button, the a butterfly will be displayed on the micro:bit dot matrix as shown in Figure 3,then Tiny-bit starts to spin right as shown in Figure 4. As shown, the spin right time is the absolute value of the accelerometer x-axis change data.
After the time is up, Tiny-bit will stop.
Until we press the A button again, shake the Tiny-bit, change the accelerometer data, and then press the B button, the Tiny-bit will spin again.
Figure 1 Figure 2 Figure 3
The code of the experiment: 13.Spinning top.rar
Playing with Tiny bit Microbit Robot Tutorial:
- Robot Kit for Micro:bit Tutorial 6.1 Measuring worker
- Robot Kit for Micro:bit Tutorial 6.2 Distance control light
- Robot Kit for Micro:bit Tutorial: 6.3 Ultrasonic obstacle avoidance
- Robot Kit for Micro:bit Tutorial 6.4 Magic hand
- Robot Kit for Micro:bit Tutorial: 6.5 Radar detector
- Robot Kit for Micro:bit Tutorial 6.6 Playing black paino
- Robot Kit for Micro:bit Tutorial: 6.7 Tracking
- Robot Kit for Micro:bit Tutorial: 6.8 Voice control light
- Robot Kit for Micro:bit Tutorial 6.9 Coward
- Robot Kit for Micro:bit Tutorial: 6.10 Musical rhythm
- Robot Kit for Micro:bit Tutorial: 6.11 Listener
- Robot Kit for Micro:bit 6.12 Wobble when touch
- Robot Kit for Micro:bit Tutorial: 6.13 Spinning top
- Robot Kit for Micro:bit Tutorial: 6.14 Frog beating
- Robot Kit for Micro:bit Tutorial: 6.15 Adventure car