THE RETURN
So I was doom scrolling and testing how wrecked my attention span can get, when I came across a reel which was a small Arduino project and it lit my curiosity and I decided to make a tony stark inspired portfolio for myself which is still a work in progress hopefully it's done before November, you can check it on https://x.com/anon5877/status/2104931447513768448?s=20. Meanwhile I was working towards building this I came across a very interesting concept which today i wanna share with you all. So sit tight we are about to learn how my keyboard and a tiny chip manage to agree with everything without a shared brain.
LORE I - Three strangers in a trench coat
I press a key. The ring LED on my desk obeys. Now the question is how?- how do they obey with no one in charge. When I press the keyboard carries its own tiny microcontroller and speaks a USB standard called HID (Human Interface Device). It has no idea that a ring exists. The OS(Operating system) hands the browser your keypress. The Browser-our second character-establishes a key distinction: it's a relay, not a boss. It passes messages; doesn't command anything. Now a tiny device called the Arduino Nano, an ATmega328P which is our third character which is also connected to the serial line but has no idea the keyboard exists. So - how do they agree ?
LORE II — The Laws of the Wire
As I searched the depths of my codebase, I found a file called PROTOCOL.md. Yes, a simple text file-and the first thing it told me was that the wire itself knows nothing. It says the wire does not know what a message says or means. Its only job is to move bytes at a fixed speed- and hand them over in whatever clumps it feels like, which means we can never control how the bytes arrive: one read can hand you half a message, or three glued together. So structure can't come from the wire. It has to come from agreement. The agreed boundary: every message is LABEL:value ** and ends with **\n. Why \n: it can't appear inside a message, so it's a safe "end here" marker. The buffer: collects bytes; whenever the delimiter appears, drain everything before it as one clean message. So: irregular bytes become messages the moment both sides agree where the fence ends.
Messages have now structure but structure isn't agreement. Anyone can shout; these two character of our story had to agree on how to behave while shouting. There's no boss , so there are certain set of rules do all the work. Four rules. A tiny constitution.
Law 1 - messages say "be at X," not "do X again" → repeats are harmless → that's why there are no acks and no retries. Its like say I have a fever and I shout repeatedly that I have a fever, the shouting will not change my fever so: it is idempotent in nature.
Law 2 - each value has one owner, the other mirrors → conflicts can't form.
| Message | Meaning | Writer |
|---|---|---|
SPEED:12 |
animation speed — 0 to 50 | browser |
POWER:200 |
LED brightness — 0 to 255 | browser |
COLOR:255,0,0 |
LED colour — r, g, b | Arduino |
Law 3 - neither device trusts the other; each clamps values into legal range on its own. So: no trust required between strangers.
Law 4 - when the nano boots, it announces where it stands; when the browser isn't sure, it asks. (That asks command is SYNC).
They don't coordinate - they follow the same polite rules.
THE SIGN-OFF
So that's the whole trick. One keypress, three strangers who've never met, and a wire that has no idea what it's carrying.
Turns out the internet runs on the exact same idea — bytes over a wire, agreed boundaries, polite rules. The whole thing, desk-sized.
They never needed a common brain. They needed a contract — and a few polite rules. Two things don't agree because someone forces them to; they agree because they both keep the same promise.
The build's still going — hopefully wrapped before November. You can watch the chaos here: https://x.com/anon5877
Thanks for reading. See you in the next one — assuming I don't vanish again.

Top comments (0)