Home > Projects > Other Projects > Make Electronic Dice using Arduino

Make Electronic Dice using Arduino

Summary of Make Electronic Dice using Arduino


This article guides readers through building an electronic die using an ATmega328 microcontroller with an Arduino bootloader. The project simulates a traditional wooden die by utilizing a mercury switch to trigger the rolling effect, which is displayed via LEDs controlled by a custom sketch. The design allows for cosmetic customization and includes options for sound effects, though these were omitted in the author's version.

Parts used in Electronic Dice:

  • ATmega328 microcontroller with Arduino bootloader
  • Eleven Arduino-compatible board
  • Mercury switch (enclosed in plastic)
  • LEDs (specifically bright blue ones mentioned)
  • ZIF-socket programming board
  • Housing box
  • Piezo buzzer (optional for sound effects)
  • Breadboard

In this project we make electronic dice.

Updated 18/03/2013

In this article you can learn how to make an electronic die (die is the singular of dice), using an ATmega328 with Arduino bootloader and a few inexpensive components. The reason for doing this is to introduce another object that you can build, learn from and be proud of. It is a fairly simple procedure, and at the end you will have something that is useful for a long time to come. Again this article will be a design-narrative, so please read it in full before making a die yourself.

First of all, here is a photo of my finished product.

Arduino Electronic Dice

Naturally the cosmetic design is up to you, I have used this box, LEDs and switches as they were already in my stock of parts.

The die is quite a simple design – with a twist. Inside the unit is a mercury switch. This consists of a small glass tube with two wires at one end and a small amount of mercury. When the mercury rolls over the wires, they are shorted out. Just like a push button when it is pushed, for example:

We will make use of this switch to start the die “rolling” – to simulate the use of a non-electronic, under-engineered wooden die. For safety, I will be using a mercury switch that is enclosed with plastic:

Over the last few years several people have contacted me saying “don’t use mercury switches”. Fair enough, if you don’t want to either, use element-14  part number 540614.

First of all, the circuit is assembled on a breadboard using our Eleven Arduino-compatible board. There is no need to build the complete independent circuit yet, as we just want to test the aspects of the sketch, and try various LEDs out. I have some bright blue ones which match with the blue housing:

Arduino Electronic Dice Schematic

Project Code and other data:

There is a function in the sketch (below) called

showNumber(int z);

The sketch is quite simple – you can download it from here.

Once the behaviour of the die met my expectation, I used my ZIF-socket programming board to upload the sketch into a nice fresh ATmega328 with bootloader. One could also add a piezo buzzer for sound effects, as described in sketch. This will end up being a birthday present for a young niece, so I have omitted the sound effects.

Major Components in Project
Arduino

 

For more detail: Make Electronic Dice using Arduino

Quick Solutions to Questions related to Electronic Dice:

  • What is the main purpose of this project?
    The goal is to introduce a buildable object that teaches electronics skills while creating a useful long-term item.
  • How does the die simulate a non-electronic wooden die?
    It uses a mercury switch that shorts out wires when the mercury rolls over them, acting like a push button to start the roll.
  • Is it safe to use a mercury switch in this project?
    The author uses a mercury switch enclosed with plastic for safety, but suggests using part number 540614 from element-14 as an alternative.
  • Which microcontroller is used for the circuit?
    The project utilizes an ATmega328 with an Arduino bootloader.
  • Can I add sound effects to the electronic die?
    Yes, you can add a piezo buzzer for sound effects as described in the sketch.
  • Where can I find the code for the project?
    The sketch can be downloaded from the link provided in the article text.
  • Do I need to build the complete independent circuit immediately?
    No, the circuit is initially assembled on a breadboard to test the sketch aspects and various LEDs before final assembly.
  • What function handles displaying numbers in the code?
    The sketch contains a function called showNumber(int z) to handle the display logic.

About The Author

Ibrar Ayyub

I am an experienced technical writer holding a Master's degree in computer science from BZU Multan, Pakistan University. With a background spanning various industries, particularly in home automation and engineering, I have honed my skills in crafting clear and concise content. Proficient in leveraging infographics and diagrams, I strive to simplify complex concepts for readers. My strength lies in thorough research and presenting information in a structured and logical format.

Follow Us:
LinkedinTwitter
Scroll to Top