Skip to main content Link Menu Expand (external link) Document Search Copy Copied
← All posts

DiceBot: The Twitter-Controlled Dice Roller

DiceBot: The Twitter-Controlled Dice Roller

It started with a 1920s antique dice tin I bought on eBay. The thing was beautiful - a small metal container with a button on the side that, when pressed, would spin the bottom and tumble a pair of dice inside. There was something satisfying about the mechanical simplicity of it, the way it required a physical interaction to produce a random result. But I couldn’t help wondering: what if you didn’t have to be there to push the button? What if this vintage piece of hardware could be controlled from anywhere in the world? That question led to DiceBot, an internet-connected dice roller that responds to Twitter commands.

Bringing Vintage Hardware Online

The original tin worked perfectly as-is. Push the button, spin the dice, check the result. But the button was the problem - you had to be physically present. So I added a small motor connected to a Raspberry Pi, which meant I could control the spinning mechanism programmatically. The L298N motor driver handled the power management, and GPIO pins on the Pi gave me the control I needed.

DiceBot hardware setup

The hardware side was straightforward enough, but the real challenge was making it useful. I wanted people to be able to roll the dice remotely, and Twitter seemed like the perfect interface. Everyone already knew how to tweet, and the API made it easy to listen for commands. So I built a Ruby script that would watch for tweets mentioning @IntrideaDiceBot with the hashtag #RollTheDice, then queue up the requests.

Reading the Dice

Once the dice were rolling, I needed a way to actually read them. That’s where OpenCV came in. I mounted a Raspberry Pi camera above the dice tin, and after each roll, it would capture an image. The computer vision code would analyze the pips on the dice and count them up. It wasn’t perfect - sometimes the lighting or angle would confuse it - but it worked well enough to be reliable.

The whole process feels magical every time it works. Someone tweets from halfway around the world, the motor spins, the camera captures, OpenCV counts, and a few seconds later that person gets a tweet back with their result and a photo of the actual roll. It’s a physical random number generator accessible to anyone with a Twitter account.

Building the Dashboard

I wanted people to be able to see all the rolls happening in real-time, so I built a web dashboard using Firebase and AngularJS. The dashboard shows a live feed of every roll, complete with photos and timestamps. It’s become a kind of digital window into this physical device sitting in our office.

The dashboard also solves a practical problem: when multiple people want to roll at the same time, we need a queue system. The Ruby scripts handle job queuing, processing requests one at a time so the dice have time to settle between rolls. It’s not the most sophisticated queuing system, but it works.

A 1920s Tin on the Internet of Things

You have this antique piece of hardware from nearly a century ago, combined with modern maker tools like the Raspberry Pi, controlled through social media, and powered by computer vision. It’s playful, but everything in it is real: real motor control, real computer vision, real job queues.

The project has been getting picked up by publications, which is exciting. Hackaday featured it as an innovative maker project. CNET wrote about it from a mainstream tech perspective. Adafruit showcased it as a Raspberry Pi project. Gizmag covered it as an innovation feature. Each publication sees something different in it - some focus on the maker aspect, others on the IoT angle, some on the social media integration.

People are starting to talk about the Internet of Things, but most examples are either too complex or too theoretical. DiceBot is neither. It’s a dice roller, some common maker components, and straightforward code, and people want to interact with it anyway. Maybe because of that, not despite it.

The part I find myself thinking about is the social layer. A physical object you can tweet at, that answers back with a photo of what it did, sits in a category that doesn’t have a name yet. I’ve been calling them social machines. Whether that name sticks doesn’t matter much; the pattern will.

What’s Next

DiceBot was never meant to be a commercial product. It’s an exploration, a way to play with how physical objects and digital interfaces can intersect. It’s a small project, but it captures something about this particular moment: connecting things to the internet is getting easier, and people are starting to imagine what that could mean.