Project 14  XGO Acceleration

Ⅰ. Teaching Aims

  1. Read the acceleration value of the on-board IMU (unit: mg or %, defined by the firmware).

  2. Use a dot matrix to “broadcast” the acceleration in real time.

  3. When the acceleration exceeds the threshold, enable XGO to provide built-in action feedback.

Ⅱ. Pre-class Check

  • XGO + Foxbit + MicroBlocks IDE.

  • XGO battery power ≥ 60 %.

  • MicroBlocks status bar shows a green dot, XGO-lite extension is loaded and the development board model is Foxbit.

Ⅲ. Key Blocks Analysis

Img

Functions

Output single-axis or composite acceleration

Tips

The firmware unit may be %(1g≈100) or mg

Img

Functions

Scroll the string to a 5×7 dot matrix

Tips

The smaller the pausing is,
the faster the scrolling speed will be

Img

Functions

Execute according to the threshold branch

Tips

< and are also available

Img

Functions

Perform the built-in wave action

Tips

When it cannot be found,
a similar action can be used as a substitute

Img

Functions

The body slides up and down,
just like breathing

Tips

Z, positive for up, negative for down

Ⅳ. Test 1: LED Scroll + Bubble Broadcast

Img

Online code: Click here

Ⅴ. Test 2: Action of Threshold

Img

Online code: Click here

Ⅵ. Quiz

  1. If the pausing 100 ms of Test 1 is changed to 20 ms, what will be the scrolling effect?

  2. What will occur in the action trigger frequency if the threshold is changed from 100 to 140 in Test 2? Why?

  3. How to calculate the composite acceleration by sqrt(accX² + accY² + accZ²) so that the threshold is independent of direction?

Ⅶ. FAQ

Questions

Possible causes

Solutions

The value of acceleration remains almost unchanged

No XGO init / IMU crash

Restart or first execute XGO init

No scrolling content on LED

In scroll text,
no acceleration is put in it

Check the block parameters

Only do half of the action

wait is too short

Set wait ≥ action duration

The entire program is lagging

Multiple long wait stacks

Replace the blocking wait with a timer