← Target Challenge worksheet Target Challenge · MakeCode

Velocity Arena · Gotham Tech

Target Challenge — the code

This drives your bot for an exact time so you can hit a target line precisely. You set one number — your drive time in milliseconds — download, and press A.

You change exactly one line: let driveMs = …. Leave everything else alone. Your SPEED is the same stat you used in the Distance Lab — set it once and don't touch it again.
  1. In MakeCode, add the Cutebot Pro extension and switch to JavaScript.
  2. Select all, delete, and paste this in (or hit Copy the code above).
  3. Set SPEED to your team's Speed stat (once).
  4. Each round: work out your drive time in ms (seconds × 1000), put it on the ★ line, Download, press A.
// ═══════════════════════════════════════════════
//   TARGET CHALLENGE — hit the line exactly
//   1. Work out your drive time in MILLISECONDS.
//   2. Put it on the ★ line below.
//   3. Download to the bot, then press A.
// ═══════════════════════════════════════════════

let SPEED = 5                     // your team's Speed stat (same as the Distance Lab). Set once.
let motorPower = SPEED * 100 / 20

let driveMs = 3600                // ★ CHANGE ONLY THIS NUMBER ★  (your time in ms)

basic.showString("A")

input.onButtonPressed(Button.A, function () {
    basic.showString("GO")
    CutebotPro.pwmCruiseControl(motorPower, motorPower)
    basic.pause(driveMs)
    CutebotPro.stopImmediately(CutebotProMotors.ALL)
    basic.showString("A")
})
Why milliseconds? basic.pause counts in milliseconds — thousandths of a second. So 3.6 seconds = 3600 ms. To go from your seconds to ms, multiply by 1000. Example: a drive time of 2.85 s → driveMs = 2850.
Velocity Arena · NYC FIRST. Used by the Target Challenge worksheet; builds on the Distance Lab equation.