micro:bit ⇄ Strudel, no cable

No USB adapter? Put the program on the board from your phone, then connect your laptop to it over Bluetooth.

Experimental. The cable version was tested end to end. This wireless version compiles but has not been run on a board yet, so expect to debug.

What you need

1 Flash from your phone

  1. Open this page on your phone and download the program:
    strudel-microbit-ble.hex
  2. Open the downloaded file with the micro:bit app (share it to the app, or find it under the app's Flash / My Programs screen).
  3. Put the board in pairing mode: hold A and B, press and release the reset button on the back, and keep holding A and B until the display fills up and then shows a pattern.
  4. In the app, choose Pair and copy the pattern from the board's display.
  5. Tap Flash. It takes a minute or two.
  6. When it finishes, the board restarts and scrolls a five-letter name such as zuvat. Write it down: that is how you find your board in a room full of them. Press reset to see it again.
  7. Close the app or turn off your phone's Bluetooth, so the phone lets go of the board.

2 Connect from Strudel

One connection carries both directions: tilt changes the filter, and the pattern drives the LEDs. Open this in Chrome on your laptop and press Ctrl+Enter.

StrudelOpen in Strudel
// micro:bit over Bluetooth: tilt -> filter, pattern -> LEDs
if (!window.mbBle) {
  const UART = '6e400001-b5a3-f393-e0a9-e50e24dcca9e'
  const dev = await navigator.bluetooth.requestDevice({
    filters: [{ namePrefix: 'BBC micro:bit' }], optionalServices: [UART] })
  const svc = await (await dev.gatt.connect()).getPrimaryService(UART)
  const chars = await svc.getCharacteristics()
  const rx = chars.find(c => c.properties.notify || c.properties.indicate)
  const tx = chars.find(c => c.properties.write || c.properties.writeWithoutResponse)
  let buf = ''
  rx.addEventListener('characteristicvaluechanged', e => {
    buf += new TextDecoder().decode(e.target.value)
    const lines = buf.split('\n'); buf = lines.pop()
    for (const l of lines) window.mbVal = (parseFloat(l) + 1024) / 2048
  })
  await rx.startNotifications()
  window.mbBle = { send: s => tx.writeValue(new TextEncoder().encode(s + '\n')).catch(() => {}) }
}

$: note("c a f e").s("sawtooth")
  .lpf(ref(() => window.mbVal ?? 0).range(200, 4000))
$: "<heart skull>".onSchedule(hap => window.mbBle.send(hap.value))
  1. Chrome shows a list of nearby Bluetooth devices. Pick BBC micro:bit [your five letters] and click Pair.
  2. The board shows a tick when your laptop connects.

You should get: a sawtooth melody that brightens as you tilt right, and LEDs alternating heart and skull.

Leave the if (!window.mbBle) { … } block alone and edit the patterns below it. window.mbVal is the tilt from 0 to 1, and window.mbBle.send("text") sends a word to the display. The ideas in the étude section all apply.

Troubleshooting

What you seeWhat to do
Your board isn't in Chrome's listMake sure your phone has let go of it (close the app), press reset on the board, and check the laptop's Bluetooth is on.
Lots of boards in the listMatch the five letters your board scrolls at startup.
The board shows a crossThe laptop disconnected. Reload the Strudel page and connect again.
Phone flashing fails or stallsPut the board back in pairing mode and try again, keeping the phone close to it.
Nothing happens after Ctrl+EnterStrudel is waiting for you to choose a device in the list near the address bar.