Introduction: D and D Dice Roller

Goal of this Instructable: Learn how to use an Arduino Uno to create an electronic "dice roller".

Why? : Sometimes, I will join my kids and play "Dungeons and Dragons". There are several types of dice used in this game. It saves time figuring out which dice to use, and it's a fun way to learn how the Arduino can communicate with seven segment displays through shift registers.

Supplies

1 - Arduino Uno

2 - Half Size Breadboards

Solid core wire suitable for use with breadboard and Arduino.

Jumper wires if desired (as seen in pictures)

2 - 74HC595 Shift registers

2 - Seven segment displays - I used common cathode in this project.

16 - 330 ohm resistors

2- 10k ohm resistors

2 - led's

2 - push buttons

Optional - if you want to run your project off of a battery:

1 - 9 volt batter

1 - 3 prong switch

Step 1: What Does the Project Look Like When You Are Done?

This is what the project looks like when it's done. No case yet. The project is running off PC power through the USB cable here. You can also run it off a 9 volt battery as pictured below. Just wire up the positive battery wire to the Arduino's Vin Power line, and the negative goes to one of the Arduino GND Power pins. There's a picture of that on the next page.

Step 2: Pictured Here Running Off a 9 Volt Battery

Step 3: Here's a Circuit Diagram Made With Fritzing Software.

Step 4: Code for the Project

I've attached my code for this project.

Step 5: Wire It Up

Follow the circuit diagram carefully. I used a wire stripper and solid core wire to keep the wires trimmed to just the size they needed to be. For some of the wires I used jumper wires from a kit. Make sure to use resistors as noted to protect your displays and leds from burning out. The buzzer is optional. It's a Piezo buzzer that beeps when you roll a 20.

Be careful when picking out your seven segment displays. There are two kinds:

  1. Common Cathode
  2. Common Anode.

You can use either kind, you just need to adjust your code and wiring for it. My project uses common cathode displays (that's what I had available).

Here's a link to an article describing the differences:

https://www.electronics-tutorials.ws/blog/7-segmen...

Step 6: What Are Shift Registers and Why Use Them?

Each segment in a seven segment display needs to be turned on or off. You can do that with 1 Arduino pin for each segment, but then you would need 14 pins to communicate to all segments of 2 displays. That's a lot of pins that most Arduino's don't have. That's where the shift register comes in.

As shown in the circuit diagram, you connect only 3 wires from the Arduino to the first shift register. That's all that's needed to send the information to the displays. If you want to use multiple 7 segment displays, you need 1 shift register for each display.

The shift registers are "daisy chained" together. So when you send 2 digits to display, the first shift register lets the first digit sent to spill over to the next shift register.

The next page has a link to a great video to learn more about shift registers and multiple 7 segment displays.

Step 7: Youtube Video Explaining How to Use Shift Registers to Run Multiple Displays

Thanks to Mario's Ideas Youtube channel for this informative video:

https://www.youtube.com/channel/UC_YUPxLXSRu_4_zCO...

Step 8: Here's a Video of the Finished Project.

Step 9: More to Come...

I plan on breaking this project down into more manageable steps. Had to publish this as is, for now. More to details to come.

Battery Powered Contest

Participated in the
Battery Powered Contest