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:
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.
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:
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:
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).
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:
https://code.google.com/archive/p/arduino-timerone...
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.
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.