Project 12 Button Control XGO
Ⅰ. Teaching Aims
Understand the triggering methods of Foxbit A/B physical buttons and the structure of event scripts.
In
when button … pressedevent, call the XGO emoji and action block.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 poseto confirm that the robot is in zero position and there is sufficient space without any obstruction.
Ⅲ. Key Blocks Analysis
|
|
|---|---|
Functions |
Detect button click |
Tips |
It can be triggered again after you release the button |
|
|
Functions |
Combined buttons |
Tips |
Both buttons must be pressed simultaneously |
|
|
Functions |
5×7 dot matrix preset emojis |
Tips |
wink, angry, heart, etc |
|
|
Functions |
Delay /anti-shake /Display time for emojis |
Tips |
30–500 ms visual effect adjustment |
|
|
Functions |
Trigger built-in fun actions |
Tips |
Firmware translation differences: PushUp /DogPee |
Ⅳ. Practice
Test 2: “PushUp/DogPee” in Joy
A: Push-up
B: Lift its leg to Pee
Corresponding script:


Online code: Click here
Ⅴ. Quiz
How to achieve the “long press for persistence”? (Tips: Poll
button A pressed?inforever)Why can adding
wait 30 msbefore and after high-time-consuming actions reduce button jitter and accidental touches?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 |
|
The action is stuck and |
Ground obstruction /Low battery power |
Clear the surrounding area; |
The emoji does not refresh. |
Long actions block the main progress |
Run emojis concurrently using |
No response when pressing A+B |
The timing of pressing the two buttons is inconsistent |
Keep pressing them simultaneously for ≥ 50ms before releasing |






