lately

I made an Etch-A-Sketch you tilt to draw

Brian Stever

2024 · ESP32, MPU6050, WebSockets, React, TypeScript

The short version. I wanted to see whether a drawing surface in the browser could borrow the physical logic of an Etch-A-Sketch. An ESP32 with an MPU6050 accelerometer streams its readings over WebSockets to a browser canvas, which draws when you tilt the controller and clears when you shake it. The result is equal parts hardware experiment, nostalgia machine and excuse to make a browser listen to a microcontroller.

1Shaking it clean

I had an Etch-A-Sketch as a kid, and what I remember most is shaking it clean. Not the drawing (I was terrible at the drawing), just the satisfaction of a total reset. Two knobs, one screen, one gesture that erases everything. It's the most legible toy interface ever made. At some point during a hardware lab it occurred to me that rebuilding it with modern electronics would be either very fun or very stupid. Those overlap more than people admit.

My version replaces the two knobs with a wireless accelerometer, which is objectively a worse input device. Instead of turning dials, you tilt a controller built around an ESP32, and it streams orientation data to a canvas in the browser. Instead of shaking the frame, you shake the controller. Shake-to-clear still works and still feels right, which says more about the original design than about mine.

2How it works

The hardware is simple: an ESP32 microcontroller and an MPU6050 accelerometer. The device samples acceleration on the X, Y and Z axes, sends the readings over a local WebSocket connection, and leaves the browser to turn them into drawing.

The browser takes each packet, turns the X and Y acceleration into a small move on the canvas, and keeps the line inside the drawing area. A separate shake detector watches for violent spikes in acceleration, and five of them within one second clear the screen. It's my first project where user rage counts as valid input.

Etch-A-Sketch frame

Requires access to the physical ESP32 device to provide live accelerometer data.

Figure 1. The browser half of the Etch-A-Sketch, connected to the physical ESP32 controller. It draws live from accelerometer data sent over WebSockets.

3From tilt to line

The interesting part isn't the canvas. It's the translation from motion to drawing. Raw accelerometer data is noisy, and if you map it straight to pixels the cursor jitters and drifts even when you think you're holding still. So the browser uses a deliberately conservative sensitivity constant and keeps movement inside the drawing area, which makes the line feel steady instead of chaotic.

I kept the connection light on purpose. WebSockets were enough. I didn't need device discovery, a pairing flow or cloud infrastructure. I needed a microcontroller to send numbers to a browser fast enough to feel immediate. Sometimes the architecture gets better when you stop pretending the project is bigger than it is.

Table 1. What the prototype does, and how.

BehaviorImplementation
Tilt to drawMap X/Y acceleration to canvas delta movement
Shake to clearDetect repeated threshold crossings within one second
Live connectionWebSocket stream from ESP32 to browser
User overridePause and clear controls in the browser UI

4What worked

It gave me the feeling I was after: a canvas you steer with motion, close enough to the real toy to set off the right kind of nostalgia. The first person I showed it to immediately tried to draw their name, then shook the controller so hard the battery cable came loose. I took that as a sign of success. The second held it like a phone and couldn't work out why it was drawing sideways. I'd assumed everyone holds things the way I do, so tilt input had more of a learning curve than I expected.

It also confirmed the usual hardware truth: demos are easier than products. The local-network setup works because I know the IP address, I know where the device is and I don't mind a little chaos. A real version would need provisioning, reconnection logic and a better plan for when Wi-Fi behaves like Wi-Fi.

5Why bother

This is why I like building with physical devices, even when the whole thing could have been simulated in software. The point wasn't to make the easiest drawing app. The point was to make a browser listen to gravity.

There's something funny about taking one of the simplest toys ever made and rebuilding it with a microcontroller, sensors, WebSockets and a React interface. I don't think the original inventors would approve, but I think they'd recognize the joy in it. And if they shook the prototype hard enough, at least the screen would clear.