Introduction: E-dice - Arduino Die/dice 1 to 6 Dice + D4, D5, D8, D10, D12, D20, D24 and D30

This is a simple arduino project to make a electronic die. It is possible to choose for 1 to 6 dice or 1 out of 8 special dice. Choice is made by simply turning a rotary encoder.

These are the features:

  • 1 die: showing big dots
  • 2-6 dice: showing dots as well as total value (alternating)
  • 4, 5, 8, 10, 12, 20, 24 and 30 faced dice showing value and indicator for chosen die
  • animation for rolling dice when pressing the button

It is possible to fit everything in a 7cm by 7cm cube including a battery. But then you would have to solder everything. I used a breadboard and some jumper wires to connect everything, hence the bigger box underneath.

To seed the arduino random numbers, I used the readout of an unconnected free pin.

Remark: This instructable will show you every step to make the e-dice work. I will add a pdf with a basic pattern for the box, however without further instructions. By putting a layer of paper over the led matrix, you make numbers and results more visible.

Remark 4 weeks later: I ported this project to an attiny85 chip, with use of progmem and a voltage divider to bypass the reset pin and use it as a button pin. Please contact me for more information.

Supplies

  • arduino (I used a nano)
  • rotary encoder (or click-encoder but we don't use the push function)
  • pushbutton
  • 8 x 8 led matrix with MAX7219 Module (fewer pins needed! 3 instead of 8)
  • wire jumpers

Step 1: Step 1: Plug in Components

  • Plug in all components so none of the pins are connected to each other. (Holes a to e are connected per line number, the same for holes f to j)
    • The arduino nano goes at the top with pins on both sides of the central pin.
    • The (click)encoder or rotary encoder goes left
    • The led matrix on the right
    • Push button at the bottom for easy access (determin which contacts are opened by pushing)
  • Use a piece of wire to connect the two "+" lines
  • Do the same for the two "-" lines (ground or gnd)

Step 2: Step 2: Connect 8x8 Led Matrix to Arduino

We use a led matrix with a MAX72XX driver. We can save up 5 pins and don't have to multiplex.

It is possible to connect multiple matrices to one MAX72xx driver. For this there is an "OUT" and "IN" side. We only use the "IN" pins.

These pins are pushed into the breadbord. You can see the pin names just under the led matrix itself. All have to be connected:

  • VCC to 5V ("+"-line)
  • GND to GND ("-"-line)
  • DIN to Arduino D12 (orange jumper)
  • CS to Arduino D10 (green jumper)
  • CLK to Arduino D11 (white jumper)

Step 3: Step 3: Connect Rotary Encoder

I used a rotary click encoder. These encoders have an extra push function (and extra pin) which we don't use in this project. You could do with an ordinary rotary encoder.

When you turn the knob, the encoder will give + or - signals compared to the original position. You can feel notches when turning. In my case I found out with Serial.print() that the encoder gave 4 steps for each notch. You have to adjust this if some of the dice types are skipped. (See code)

Connect the encoder as followed:

  • GND to GND ("-"-line) (small piece of black wire)
  • + to 5V ("+"-line) (small piece of red wire)
  • SW to nothing (this is the switch, which we don't use.)
  • DT to A1 (orange jumper)
  • CLK to A0 (white jumper)

Step 4: Step 4: Button and VCC

In my first version I used a button with an extra resistor. However in the arduino IDE you can set the use of a pull_up resistor. With this you don't need an extra resistor, but you have to do a little inverse in the code, reading this button.

Simply connect one end of the button with GND ("-"-line) and the other end with D2 (blue jumper).

The last connection to be made: a wire from the Arduino 5V to the "+"-line for using the regulated 5V of the arduino.

After these steps all connections are made to make a working version.

Remark: You could add a battery. Connect the battery with + to VIN and - to GND ("-"-line).

Step 5: Step 5: the Code

Open the Arduino IDE.

You can download the zip files for the libraries which are not available through the "Library Management' in the IDE.

Make sure you add the following libraries through "Library management" or add library manually in the IDE:

  • LedControl by Eberhard Fahle v1.0.6
  • TimerOne by Jesse Tane, Jérôme Despastis, ... (I downloaded and installed manually version r11 from:

    https://code.google.com/archive/p/arduino-timerone...

  • Encoder by Peter Dannegger found on https://github.com/0xPIT/encoder

I use Peter Danneggers library because he added a function to give the encoder acceleration sensitivity: Spinning faster makes the numbers go up faster.

Once those libraries are installed, you should be able to open and compile the edice.ino file.

Step 6: Step 6: Make It Pretty...

I like to reuse my arduino's so I seldom solder a project or do an effort to make it look nicer. I like the nerdy style of wires and jumpers...

However I made this small template to hold all components. If you place the box with numbers 30 to 4 printed on white paper over the matrix, the separate led encasings distract less. As a bonus, the leds in the top row will show you which of those special dice was chosen.

EDIT: I made a version with an attiny85 digistump spark, in a nice lasercut box.De knob is used to choose the die as well as a pushbutton.