Open your tools
Your stat formulas in JavaScript
| Stat | Formula | JavaScript |
|---|---|---|
| Speed | Motor power = (Speed / 20) × 100 | roamPower = SPEED * 100 / 20 |
| Power (charge) | Charge speed = Power² / 2 | chargePower = POWER * POWER / 2 |
| Power (follow-through) | Follow through = Power × 80 | FOLLOW_THROUGH_MS = 120 + POWER * 35 |
| Turning (segments) | Arc segments = Turning | arcSegments = TURNING |
| Turning (ratio) | Turn ratio = 0.2 + (Turning × 0.02) | turnRatio = 0.2 + TURNING * 0.02 |
| Endurance | P(t) = 100 − (20 − E) × 1.5 × t | DECAY_RATE = 20 - ENDURANCE |
Your four stats must always total exactly 20: SPEED + ENDURANCE + TURNING + POWER = 20. The dashboard enforces this. If you're over budget, reduce one stat before saving.
How to get code onto your bot
Open MakeCode. Edit your stat values at the top of the code. Change let SPEED = 5 to whatever your stat card says.
Click the purple Download button. A .hex file saves to your computer.
Plug in the micro:bit via USB. It shows up as a drive called MICROBIT. Drag the .hex file onto that drive. The yellow LED blinks while it loads. When it stops blinking, your bot is ready.
JavaScript basics for Velocity Arena
| Concept | What it looks like | What it does |
|---|---|---|
| Variable | let SPEED = 5 |
Stores a number with a name. Change the number, change the bot. |
| Function | function computeStats() { ... } |
A reusable block of code. Call it by name to run it. |
| If/Else | if (borderSide > 0) { handleBorder() } |
Makes a decision. If the condition is true, run the code inside. |
| Loop | for (let i = 0; i < TURNING; i++) { ... } |
Repeats code a set number of times. TURNING controls how many arc segments. |
| Math | POWER * POWER / 2 |
Same operations as your stat card. JavaScript uses * for multiply and / for divide. |
| Event | input.onButtonPressed(Button.A, function() { ... }) |
Runs code when something happens. Button A starts the match. |
Common problems
Is the battery plugged in and charged? Is the power switch on? Did you download the .hex file to the MICROBIT drive (not your Downloads folder)?
Check your Speed stat in the code. let SPEED = 2 gives only 10% motor power. Your stat card tells you the right number.
Your Turning value might be too high or the turn ratio formula is off. Check turnRatio = 0.2 + TURNING * 0.02 and make sure your TURNING stat matches your card.
Low Endurance = fast decay. ENDURANCE = 2 means your bot loses power at 27% per minute. If you can't finish a 3-minute match, plan for more Endurance the next time you set your loadout.