Skip to content

Latest commit

 

History

2 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Space Invaders :: micro:bit Edition

A browser-based Space Invaders clone controlled by a BBC micro:bit v2 over Bluetooth Low Energy (Web Bluetooth API). Tilt the micro:bit left/right to move your ship; press Button A or B to fire. A keyboard fallback (arrow keys + space) is included for testing without hardware.

1. Flash your micro:bit

The browser talks to the micro:bit's standard Bluetooth Accelerometer Service and Button Service, so the micro:bit just needs Bluetooth enabled with those services advertised — no custom firmware logic required.

Easiest way, using MakeCode:

  1. Create a new project.
  2. Drag in the bluetooth category blocks (search "bluetooth" in the toolbox) — add:
    • bluetooth accelerometer service
    • bluetooth button service under on start.
  3. Go to Project Settings → micro:bit version and make sure it's targeting V2 (BLE pairing-free mode works best on V2).
  4. Download the .hex file and drag it onto your micro:bit (it mounts as a USB drive).
  5. After flashing, the micro:bit will restart and begin advertising as BBC micro:bit [xxxxx].

Note: the default "radio" firmware that ships on a fresh micro:bit does not advertise these GATT services — you must flash a MakeCode (or other) program that explicitly adds the bluetooth blocks above.

2. Serve this site

Web Bluetooth requires a secure context (HTTPS or localhost) — opening index.html directly via file:// will not work.

From this folder, run any static server, e.g.:

python -m http.server 8080

Then open http://localhost:8080 in Chrome or Edge (Web Bluetooth isn't supported in Firefox/Safari).

3. Play

  1. Click Connect micro:bit and select your device from the browser's pairing dialog.
  2. Tilt the micro:bit left/right to steer your ship.
  3. Press Button A or Button B to fire.
  4. Click Start Game.

No micro:bit handy? Click Play with Keyboard Instead and use Arrow keys + Space.

Project structure

index.html        Page layout / HUD
css/style.css      Styling
js/microbit.js     Web Bluetooth wrapper for the micro:bit GATT profile
js/game.js         Canvas-based game engine (input-agnostic)
js/main.js         Wires micro:bit + keyboard input into the game

About

Play Space Invaders with the micro:bit v2

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages