
Get full C++ & Python code + lifetime access
Flick a breadboard to make the bird flap. An ESP32S reads an MPU6050 motion sensor and sends every movement to a browser game over USB. A quick flick upward makes the bird flap. There are no buttons and no joystick, just motion.

| | | |---|---| | Microcontroller | ESP32S (NodeMCU-32S, 38-pin) | | Sensor | MPU6050 6-axis gyro + accelerometer (GY-521 module) | | Connection | USB serial at 115200 baud, read in Chrome with the Web Serial API | | Game | Single HTML file: retro pixel-art flappy game written in JavaScript | | Controls | Flick up to flap (or tilt mode), BOOT button, keyboard fallback | | Update rate | 100 sensor readings per second | | Cost | About $3โ5 in parts |
How it works in one line:
MPU6050 โ (IยฒC) โ ESP32S โ (USB serial) โ Chrome (Web Serial) โ gesture detection โ flap!
| Qty | Part | Notes | |---|---|---| | 1 | ESP32S NodeMCU-32S | Any 38-pin ESP32 dev board with the same pinout works | | 1 | MPU6050 module (GY-521) | Gyroscope + accelerometer breakout | | 1 | Breadboard | Half-size fits nicely in your hand | | 4 | Jumper wires | Red, black, yellow, blue | | 1 | Micro-USB data cable | Charge-only cables won't work |
| MPU6050 pin | ESP32S pin | Wire colour | Purpose | |---|---|---|---| | VCC | 3V3 | ๐ด Red | Power (3.3 V) | | GND | GND | โซ Black | Ground | | SCL | GPIO 22 | ๐ก Yellow | IยฒC clock | | SDA | GPIO 21 | ๐ต Blue | IยฒC data | | XDA, XCL, AD0, INT | โ | โ | Leave unconnected |
ESP32S NodeMCU-32S MPU6050 (GY-521)
โโโโโโโโโโโโโโโโโโโโโ โโโโโโโโโโโโโโโโ
โ 3V3 โโโโโโโโโโโโโโโผโโโโ red โโโโโโโโบโโ VCC โ
โ โ โ โ
โ GND โโโผโโโโ black โโโโโโบโโ GND โ
โ GPIO 22 โโโผโโโโ yellow โโโโโบโโ SCL โ
โ GPIO 21 โโโผโโโโ blue โโโโโโโบโโ SDA โ
โ โ โโ XDA (n/c) โ
โ [EN] [BOOT] โ โโ XCL (n/c) โ
โ โโ BOOT = start / flap โโ AD0 (n/c) โ
โโโโโโโโโโฌโโโโโโโโโโโ โโ INT (n/c) โ
โ micro-USB โ PC โโโโโโโโโโโโโโโโ
Note: Power the MPU6050 from 3V3, not 5V. The on-board BOOT button (GPIO 0) also works as a flap / start button, so no extra button is needed.
https://espressif.github.io/arduino-esp32/package_esp32_index.json
flick_bird_controller/flick_bird_controller.ino.READY
T,0.52,-1.13
T,0.55,-1.10
flick_bird_classic.html in Chrome or Edge on a computer.| Action | Breadboard | Keyboard / mouse | |---|---|---| | Flap | Quick flick up | Space, โ, W or click | | Start / retry | Flick or BOOT | Space, Enter or click | | Full screen | โ | F | | Pause | โ | P | | Mute | โ | M | | Re-centre (tilt mode) | โ | C |
Browsers only allow full screen from a key press or click. If you start with a flick or the BOOT button, press F once and it stays full screen.
The ESP32 talks to the MPU6050 directly over IยฒC (no libraries) and calculates the board's angle 100 times a second.
// Wake the sensor and set it up
writeReg(0x6B, 0x01); // wake up, use gyro clock
writeReg(0x1A, 0x03); // low-pass filter ~44 Hz
writeReg(0x1B, 0x08); // gyro range ยฑ500 ยฐ/s
writeReg(0x1C, 0x00); // accel range ยฑ2 g
// Every 10 ms: read gyro + accelerometer, fuse them
roll = 0.98 * (roll + gyroX * dt) + 0.02 * accRoll;
pitch = 0.98 * (pitch + gyroY * dt) + 0.02 * accPitch;
// Send to the PC
Serial.printf("T,%.2f,%.2f\n", roll, pitch);
Why mix gyro and accelerometer (complementary filter)?
Serial messages
| Message | Meaning |
|---|---|
| T,<roll>,<pitch> | Board angles in degrees, 100ร per second |
| BTN | BOOT button pressed |
| READY | Sensor found and calibrated |
| ERR,<message> | Sensor not found; the firmware retries every second |
The browser reads the serial lines and works out how fast the board is rotating:
// angular speed in degrees per second
const raw = (angle - previousAngle) / 0.01; // samples are 10 ms apart
rate += (raw - rate) * 0.5; // light smoothing
Flick mode (default)
if (armed && rate > 150) { // fast upward flick
flap();
armed = false; // one flap per flick
}
if (!armed && rate < 45) { // board has slowed down again
armed = true; // ready for the next flick
}
Tilt mode
| Setting | Default | What it does | |---|---|---| | Flap gesture | Flick up | Flick up or Tilt up | | Flick strength needed | 150 ยฐ/s | Lower = easier to flap | | Tilt needed | 15ยฐ | For tilt mode | | Use the other axis | Off | If flicking up does nothing | | Invert direction | Off | If flicking down flaps instead of up |
Calibrate in 10 seconds: open Settings and flick the board up. The bar should jump past the gold line and flash. Lower the slider if flicks are missed, or raise it if the bird flaps on its own.
| Problem | Fix |
|---|---|
| ERR,MPU6050 not found | Check VCC โ 3V3, GND โ GND, SDA โ 21, SCL โ 22. Push the jumpers in firmly. |
| No port in the Arduino IDE | Use a data cable and install the CP210x driver. |
| "Could not open the port" | Close the Arduino Serial Monitor. |
| Connect button does nothing | Use Chrome or Edge on a computer. Safari and Firefox don't support Web Serial. |
| Flicking up doesn't flap | Turn on Use the other axis, or Invert direction. |
| Bird flaps by itself | Raise Flick strength needed in Settings. |
| Flicks get missed | Lower Flick strength needed, and flick sharply rather than slowly. |
| Upload fails ("Failed to connect") | Hold BOOT while the IDE says Connectingโฆ. |
flick-bird/
โโโ flick_bird_controller/
โ โโโ flick_bird_controller.ino # ESP32S firmware
โโโ flick_bird_classic.html # Retro pixel version (main game)
โโโ flick_bird.html # Alternate sunset / circuit-board version
โโโ tilt_pilot_wiring.png # Wiring diagram
โโโ README.md
T,roll,pitch stream works for racing, maze or space-shooter gamesMade by Ravi Paribrajak ยท If you build this, tag me! ๐ฆ