Electronic Stabilizer | Boson starter for micro:bit 10

0 3523 Easy
projectImage
projectImage
projectImage
projectImage
projectImage

STEP1: Connect the servo to the pin P0 of micro: bit expansion board.

projectImage

STEP2: Programming

1. Drag the “read acceleration” block in micro: bit module to script area. It can be used to get the acceleration of X, Y and Z axes.

projectImage

2. The output value of the accelerometer ranges between -1023 and 1023, and we can use “display” block to check it.

projectImage

3. When micro: bit board is titled to the left, a negative output value will be produced along the X direction, so we need the servo to rotate toward right to compensate this angle.

projectImage

Here we have to use “map” function. Mapping the value of accelerometer’s X axis (-1023~1023) onto the degree that the servo rotates (0~180 degree). After mapping, when the board lays flat on the desktop, the angle of the servo will be 90 degrees. The corresponding relations show as Table 4.1.1

projectImage

Find “map…from…to…” block in “Operators” module.

projectImage

4. Click Expansions->Actuator->Micro Servo and back to the former interface.

projectImage

5. Drag “set pin servo to… degree” block to script area, and put it inside the “forever” block, then nest the “map…” block into it. Shown as below:

projectImage

6. Fix the servo onto the expansion board with double-side adhesive tape so that they both remain relatively still.

projectImage
projectImage
projectImage
License
All Rights
Reserved
licensBg
0