Project 12 Button Control XGO

Ⅰ. Teaching Aims

  1. Understand the triggering methods of Foxbit A/B physical buttons and the structure of event scripts.

  2. In when button pressed event, call the XGO emoji and action block.

  3. Map the two buttons to “Emoji Switch” and “Fun Action” respectively, and you can expand custom combination keys.

Ⅱ. Pre-class Check

  • XGO + Foxbit + MicroBlocks IDE.

  • XGO battery power ≥ 60 %. The robot is placed on a flat ground.

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

  • First, run XGO reset pose to confirm that the robot is in zero position and there is sufficient space without any obstruction.

Ⅲ. Key Blocks Analysis

Img

Functions

Detect button click

Tips

It can be triggered again after you release the button

Img
Img

Functions

Combined buttons

Tips

Both buttons must be pressed simultaneously

Img

Functions

5×7 dot matrix preset emojis

Tips

wink, angry, heart, etc

Img

Functions

Delay /anti-shake /Display time for emojis

Tips

30–500 ms visual effect adjustment

Img

Functions

Trigger built-in fun actions

Tips

Firmware translation differences: PushUp /DogPee

Ⅳ. Practice

Test 1: Button Control Emoji

  • Ahappy

  • Bsad

Corresponding script:

Img

Img

Online code: Click here

Test 2: “PushUp/DogPee” in Joy

  • A: Push-up

  • B: Lift its leg to Pee

Corresponding script:

Img

Img

Online code: Click here

Ⅴ. Quiz

  1. How to achieve the “long press for persistence”? (Tips: Poll button A pressed? in forever)

  2. Why can adding wait 30 ms before and after high-time-consuming actions reduce button jitter and accidental touches?

  3. If you want to change “press button A” to a random emoji, which two blocks need to be added?

Ⅵ. FAQ

Questions

Possible causes

Solutions

The button has no response.

Poor contact /Insufficient anti-shake

wait 30 ms in the first line of the event;
Check the solder joints of the buttons

The action is stuck and
does not return to its original position

Ground obstruction /Low battery power

Clear the surrounding area;
Battery power ≥ 50%

The emoji does not refresh.

Long actions block the main progress

Run emojis concurrently using launch,
or display them after the action is completed

No response when pressing A+B

The timing of pressing the two buttons is inconsistent

Keep pressing them simultaneously for ≥ 50ms before releasing