How To Use LEGO Bricks For Data Storage

A system that stores data on LEGO bricks

Those old enough to have encountered punch cards in their lifetime are probably glad to be rid of their extremely low data density and the propensity of tall stacks to tip over. But obsolete as they may be, they’re a great tool to show the basics of binary data storage: the bits are easily visible and can even be manipulated with simple tools. As an experiment to re-create those features in a more modern system, [Michael Kohn] made a punch card-like system based on LEGO bricks that stores machine code instructions for a 65C816 CPU, the 16-bit successor to the venerable 6502.

Bits are stored on a white 8×20 stud board, onto which small black pieces are placed. A white background stud encodes a logic “zero”, while a black stud encodes a logic “one”. The bits are read out by an array of reflectance sensors, which conveniently has the same 8 mm pitch as standard LEGO studs. A big wheel driven by a stepper motor slides the data card under the readout circuit along a short stretch of LEGO train tracks.

The optical sensors are read out by an MSP430 series microcontroller, which also drives the motor through a stepper motor driver. Once the data is read out, the bytes are transferred into a WDC W65C265SXB board, which executes them as machine code instructions on its 65C816 CPU. In the video below, you can see a program being loaded that blinks an LED.

We’ve featured educational punch-card systems before, like this Raspberry Pi-based model. If you’ve got a bunch of actual punch cards that need reading out, check out this Arduino-powered readout system.

10 thoughts on “How To Use LEGO Bricks For Data Storage

      1. 256-bit is a good length for a symmetric key (for instance AES), fo a private key at least 2048-bit is recommended and you would need a second card for the public key.

  1. Ah punch cards. I remember those days. The best (maybe only good thing) about them was that if you dropped a card deck you sometimes had the “opportunity” forced on you to rewrite your program. And it usually came out better the second time.

    1. I seem to remember one would draw a diagonal mark across the top of the deck so you could get them back in order.

      Also, in the university’s terminal room, they had a vending machine set up so one could buy unpunched cards.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.