Pocket Dice! Electronic Dice for Liars Dice and More

9,968

107

16

Introduction: Pocket Dice! Electronic Dice for Liars Dice and More

About: Background in chemical engineering with an interest/hobby in electronics, coding, 3D printing, crafting, woodworking.

In this instructable, I will show you how I made this set of electronic dice. This is a small handheld device that contains 5 individual die with a button that initiates a random roll. The switch is used to turn each die on or off so depending on the game one is playing, 1-5 dice can be used.

The inspiration for this project came during quarantine when many of the card and board games we own were running out of fun. For something different, I wanted to play a dice game called Liars Dice which is a fun, strategic, betting game. The problem is that each player needs 5 dice and a place to roll/cover their die. So, I decided to design and build an electronic set of dice. Pocket Dice was originally designed around the game Liars dice but its functionality can be extended to all games that use 1-5 dice.

When coming up with this idea, I had a few design challenges and requirements:

  1. Make the overall design as compact as possible which would require the use of mostly surface mount components.
  2. I wanted to utilize an Attiny85 microcontroller which is fairly robust in its functionality for its size.
  3. Because the number of I/O pins are limited by the Attiny, I needed to find a suitable LED driver IC. The one I settled on was a MAX7219 chip which can drive up to 64 LEDs with only 3 inputs!
  4. It had to be battery powered to maintain its portability.
  5. Because I was replacing traditional die, I wanted to make the look and feel of the electronic die as real as possible.

With all of these design requirements in mind, a custom PCB was essential and I utilized easyEDA and JLCpcb for the design and fabrication. Follow along for the build process and list of supplies below. The focus of this project will be on the PCB design and will be helpful for anyone that may be new to this process!

Supplies:

Electronics:

Other:

  • 3D printer (optional)
  • Black and White PLA filament
  • solder/ solder paste
  • sandpaper
  • super glue

Step 1: Breadboard Prototyping

The first step in most electronics projects includes temporarily wiring everything up to make sure the circuit is correct. Once the proper connections are made, the coding/programming can be done. Because in my final design, I was using mostly surface mount components including the MAX7219 IC led driver, I purchased the equivalent DIP version for prototyping.

My plan was to first understand how the MAX7219 IC functioned. The website by Eberhard Fahle was incredibly helpful and contains information about the proper hardware and software setup for this IC. Because I am more familiar with Ardunio programming and there is fairly significant crossover between Arduino and the Attiny85, I chose to do the initial testing/programming with an Ardunio mega.

After learning about how the MAX7219 works, I converted the seven segment display configuration to each face on a die. Please follow the attached 7 segment Dice Equivalent document for more information. My initial tests included writing a simple program to interface between the ardunio and the MAX IC wired up to 7 LEDs (that would make up the die face). This worked well and confirmed that I had properly done the conversion between the seven segment output and die faces.

Now it was time to add the rest of the die into the circuit. Please follow my schematic below for all of the proper connections. I had wired this all on a breadboard and the mess of wires only convinced me more how crucial a custom PCB would be to maintain the form factor I wanted. Once all of the "dice" were wired up I could move on to the I/O circuit.

I added an on/off switch, the push button, and the piano DIP switch to control each "die" individually. The push button would control each random roll. The output and wiring of the MAX7219 allowed me to simply integrate the piano DIP switch to turn each die on and off by using the he common cathode (DIGIT) pins.

Step 2: Programming

Like I had mentioned in the last step, I started and completed the programming on an Arduino. Once I was happy with how everything worked, I converted the program to work on an Attiny85. Even though the IDE is the same between the Attiny and Arduino the libraries and functions are not the same. This was a pretty big challenge for me and I utilized multiple resources to "convert" my original program to work on the Attiny85. I did learn a lot but still do not understand enough to be able to describe the whole process as it was more of a trial-and-error experience. I have attached both versions of my code so that you can compare them. I hope to create more projects with the Attiny in the future to learn more and become more familiar with it.

A few features of my code included the push button input for a roll. In any dice game, players often shake the dice for variable amounts of time before they roll. I wanted to include this feature into my electronic dice by rolling with the push of a button and continue to "shake the dice" if the button is held. Once the button is released, the roll is initiated and a random number appears on each die.

Another feature that I included was the rolling animation and an initiated roll animation. You can see this in action in the video above. This was easily accomplished using the seven segment conversion document attached in the previous step.

Overall the code is fairly simple and uses pretty basic conditional loops. I have tried to comment the attached code so that you can follow along and understand each step. The Arduino program makes use of the "LedControl.h" library which makes interfacing with the MAX7219 very easy. The Attiny85 program can't take advantage of this library so you'll see a more manual approach to interfacing with the Max IC.

Step 3: PCB Design

Now that I had a working program and schematic, it was time to convert the schematic into a PCB. As mentioned above I utilized easyEDA to accomplish this. Please see the online user guide for more in-depth use of easyEDA but I will describe the complete process below for my Pocket Dice. Feel free to skip ahead if you are not interested in the process and just want the final Gerber files or if you are familiar with the PCB design process.

1) I will first start with developing the schematic. Once you create a login for easyEDA, go to file>new project. Insert a title and click save. This will open a blank schematic file.

2) Next you want to start populating the schematic with all of the relevant parts. To do this, go to Library on the side panel. In the search bar, start typing identifiers for your specific component. For example type attiny85 and select option "user contributed" which will query the entire list of schematic and PCB layout of that specific component that others have added. The list can be overwhelming to go through and often there are many duplicate components. The important thing to check is that the pinout and PCB "footprint" is the same for the specific component that you are using. (If you are using a through-hole component, confirm that the footprint is a through-hole component and not a surface mount or different package). This is quickly verified by the preview window on the right. Once you are happy with the component you've selected, click place. This will allow you to add it to your schematic. Continue this process for the rest of the components you will be using in your project.

3) Now that you have all of your components placed, I think its easiest to group components together that will eventually be wired together and rename all of the appropriate components to keep them straight (especially during the PCB design part). I renamed all of the LEDs into a seven segment format as seen above.

4) Next I add VCC and GND to all of the components on the circuit. Click on VCC and GND in the Wiring Tools box to place them in the schematic.

5) Once that's done you can begin using the Wire tool to connect individual components. You click on the Wire in the Wiring Tools. This changes your cursor to a crosshair then click on one lead of a component and then click on the other lead to connect them. Again I think its easiest to start with a part of the circuit. For me, I started with the wiring between the Attiny and max chip and progressed in groups from there.

6) To avoid making the diagram busy with tons of crossing wires, another Wiring tool is the NetPort. This can be used to connect components without a physically drawn wire between them. As long as the NetPort is the same name, they are connected. I used this to simplify the schematic.

7) Once your schematic is complete its time to start designing the PCB. Go to Design>convert to PCB and it will take you to a new window with all of the component footprints and nets between each component.

8) I begin by rearranging all of my components into the general layout that I want. I started with the LEDs and arranging them in the form of dice. You can add shapes, texts, images, using the PCB Tools and the specific layer can be selected using the Layers and Objects tool box. I started adding the outline of a die to the TopSilkLayer. I used the dimensions of a real die as a guide. The dimension tool in PCB Tools helped me get the proper spacing.

9) Once all of the components are arranged, front and back on the PCB. It is time to start adding the copper tracings. In PCB Tools select Track and begin connecting the components based on the purple nets between them. An automatic via will be added if you switch between TopLayer and BottomLayer. Make sure to not cross any tracks on the same layer or this will alter your circuit. (After all tracings have been made, some people will flood the both sides of the PCB with copper however, I did not do this before fabricating).

10) Next draw the outline of the PCB once you have the BoardOutline selected in the Layers and Objects tools. This will determine the final size and should contain all components of your circuit.

11) Once all of the tracings are complete, the board outline is set, and you are satisfied with the silkscreen text, you are ready to create your Gerber files. Go to Fabrication>PCB Fabrication File(Gerber). The program will to a Design rule Check to evaluate all of the tracings are within specification of default fabrication specs. Any errors will populate and give you a chance to fix them before the Gerber files are generated. JLCpcb is associated with EasyEDA and after the Gerber files are generated it will take you to JLC to complete the order. Fill out all of the shipping and payment info and your PCB fabrication will begin!1

Step 4: PCB Assembly

After your custom PCBs arrive, it is time for assembly. Because I have chosen many SMD components and have recently made a reflow oven, I chose to order a stencil to aid in the soldering process. I started with the LED side, placed the stencil on top, spread the solder paste and lifted the stencil. Now that all of the pads contained the paste, I placed all of the LEDs using tweezers. It is important to place the LEDs in the correct orientation. After placing all of the LEDs, I reflowed the board in my oven.

Next I flipped over the board and used the stencil for the back side. I placed all of the components and used a soldering iron to melt the paste and solder all of the components to that pad.

Then I moved on to all of the through hole components. Once those were soldered the board is complete!

****At this point I had done initial breadboard testing and still planned on using a coin cell battery as per the schematic and board layout. After assembly and testing the coin cell battery was not an adequate power source to run the board for any extended amount of time. I chose to remove the coin cell battery holder and solder the LiPo battery directly to the pads. I wired an additional JST connecter for charging the LiPo. ****

The LiPo battery is an excellent power source for this tiny device and is convenient to recharge in between game play. I finished soldering the rest of the boards now that I know everything works!

Step 5: 3D Printing

The next step was to 3D print the dice. I used Fusion360 to complete this process. Each die cap was dimensioned to mirror the silk screen dimensions. The cap was printed in white PLA. The black spacer piece will fit inside to make the dice look more realistic when the board is off. I had initially printed this in black PLA on a standard FDM printer but was not satisfied with the look of the final part. I had brief access to an SLA printer and used black resin to print the spacer pieces I used in my final Pocket die version. Next, was the design and print of the LED divider. This separates the SMD LEDs so that there is not any "bleeding of light" between the different pips on the die.

Then I designed a case to hold the PCB. The case serves as a way to hold and play the game but also protects the PCB when it is in your pocket. Each case was printed in black PLA on a standard FDM printer. Mounting holes were designed to line up with the holes drilled into the PCB.

Step 6: Finishing the Dice

The 3D printed parts are rough right off of the printer. I was going for a look that would be as close to a real die as possible and this required a lot of sanding and finishing to achieve that look. I also wanted a way to diffuse the LED light shining though the pips. I decided to use clear 3D filament as little "plugs" inside the black spacer. I cut and glued those pieces of filament inside the pip holes.

Once the glue had dried on the spacers, I used 60 grit sandpaper to sand the excess filament protruding from the black spacer. Next I removed the brim from the white caps and began sanding and shaping the die into their final shape. I tried to mimic the shape of a real die as much as possible. For the white cap and black spacer, I progressed through increasing grits of 220, 400, 800, 1000, 3000 to get a very smooth finish. I also used a miniature file set to shape the holes in the white caps. I was very happy with the final results.

After the sanding was complete, I began press fitting the black spacer into the white cap. Next I glued the divider piece into the back of the cap. Finally I glued the assembled Die caps onto the PCB aligning them with the silkscreen layout.

I did some light sanding of the 3D printed case after removing it from the printer. Next I used 12mm M2 brass standoffs to fit in printed case and used super glue to secure them. Once the glue dried, I used a saw to cut off the excess standoff on the bottom of the case. Next I placed each PCB into the case and secured them with M2 hex screws. Now your Pocket Dice is complete!!

Step 7: Final Thoughts

This has been a fun project and a great learning experience. I have much more to learn and want to utilize the Attiny85 in more projects. Power management is important and was something that I had to fix along the way. The LiPo ended up being a much better option and still fit within my initial size constraints. As I had mentioned in the introduction, Pocket Dice was originally designed to play the Liars Dice game but it can be used in a ton of other games.

I am very happy with how Pocket Dice has turned out and enjoy the portability. I hope you get inspired to make your own set or this convinces you to try fabricating your own PCB. Happy making!

PCB Challenge

This is an entry in the
PCB Challenge

Be the First to Share

    Recommendations

    • Make it Glow Contest

      Make it Glow Contest
    • First Time Author Contest

      First Time Author Contest
    • PCB Challenge

      PCB Challenge

    16 Discussions

    1
    gwhip70
    gwhip70

    Question 4 days ago

    Do you still have the gerber files? The link to easyeda returns a 404 error.

    0
    sunyecz06
    sunyecz06

    Answer 3 days ago

    Yes. Check your inbox for a link to the files.

    0
    gwhip70
    gwhip70

    Reply 20 hours ago

    Thanks! Also, the capacitors aren’t listed in the list of parts. I hope you win.

    0
    sunyecz06
    sunyecz06

    Reply 18 hours ago

    You're right. Just added them!

    0
    gwhip70
    gwhip70

    Reply 13 hours ago

    I’m not good with electronics, wondering if you thought something like this would work for charging the battery. I can modify the case for it to fit. TP4056 Micro USB Type C 5V 1A Lithium Battery Charging Protection Board TE585 Lipo Charger Module
    https://a.aliexpress.com/_mOREW1T

    0
    sunyecz06
    sunyecz06

    Reply 8 hours ago

    The particular lipo that I used in this project can only be charged with a max rate of 450mA. I would be hesitant to use the one you linked because it charges at a max rate of 1000mA and there is not much documentation on if that is adjustable. Here's what I use: https://www.adafruit.com/product/1304 which charges at a rate of 100mA. It also has a JST connector which is convenient to easily plug in the battery.

    0
    ScienceDiscoverer
    ScienceDiscoverer

    3 days ago

    I like how it actually resembles real dice. Other projects like this just use LCD screens with numbers, that really ruin their devices appeal!

    0
    sunyecz06
    sunyecz06

    Reply 3 days ago

    That was definitely one of the main goals for this project. Thanks!

    0
    sunyecz06
    sunyecz06

    Reply 3 days ago

    I’m glad you liked it! I’m happy to share my gerber files if you plan to make this project.

    2
    roaldh
    roaldh

    7 days ago

    I like your design!

    0
    sunyecz06
    sunyecz06

    Reply 7 days ago

    Thank you!

    3
    jessyratfink
    jessyratfink

    7 days ago

    That looks so professional :D

    0
    sunyecz06
    sunyecz06

    Reply 7 days ago

    Thanks!

    3
    hugheswho
    hugheswho

    7 days ago

    Excellent project! I love playing liar dice - such a great game. This is such a compact solution, too.