Introduction: Modern Dice

Picture of Modern Dice
I like playing dice games like mensch, snakes & ladders, yahtzee, and …. Nowadays everything appears in modern form, so it must be very fun to have a modern dice, an electronic dice with LEDs and a microcontroller. If you want to make a modern dice follow this instructable.

Step 1: What You Need

Picture of What You Need
To make this dice you need the following components and tools:
  • Printed circuit (find files in the next step)
  • Copper board
  • Sandpaper
  • Iron
  • Circuit board acid
  • 1mm drill
  • Soldering tools
  • 1x PIC12F675 microcontroller + socket
  • 7x 5mm LEDs
  • 7x 470ohm resistors (1/8 watt)
  • 1x 10k resistor
  • 1x Simple push button
  • 1x 3V coin battery + battery holder(I couldn't find a battery holder so I made it myself)

Step 2: Making the PCB

Picture of Making the PCB
First you need to make a PCB. Here is a good instructable for making PCBs.
  1. Print the circuit on a glossy paper with a laser printer without scaling.
  2. Cut some copper board and clear it with sandpaper.
  3. Put the printed circuit on it.
  4. Press the hot iron on the board.
  5. Remove the papers.
  6. Soak boards in acid and wait till visible copper disappears.
  7. Wash the board.
  8. Drill the holes.
  9. Clear the board with sandpaper.
**The images are not for this project.

Step 3: Soldering Components

Picture of Soldering Components
Now it's time to solder components on the board. Here is a good instructable for Soldering.
  1. Solder 470ohm resistors on the board (the resistor that is drawn on the IC is 10k not 470ohm).
  2. Solder microcontroller socket on the board in correct direction.
  3. Solder the LEDs on the board. Note that the cathode side is hatched.
  4. Solder the 10k resistor (the resistor on the IC) on its place on the back side of the board.
  5. Solder the button on the back side of the board to the terminals marked with letter B.
  6. At last solder two wires to the + and - terminals for the power supply.

Step 4: Attaching the Battery Holder

Picture of Attaching the Battery Holder

Put some insulator among button and the board and attach the button to the board with glue.
Solder the power supply wires to the battery holder.
Now attach the battery holder to the board on the button using some flexible material like paper and glue.
Note that at last you must be able to push the button by pushing the battery holder.

Step 5: Programming

Picture of Programming
Download the following file and program your PIC12F675 microcontroller. You can use any programmer to do this, I am using WinPic with a JDM programmer. After programming your microcontroller place it on its socket on the board.
Don't forget to:
  • Set oscillator to internal RC without CLKOUT (INTOSC no CLKOUT)
  • Disable power-up timer
  • Disable watchdog
  • Set MCLR to input pin
  • Disable brown-out reset
In other words: config word ($2007) = 0x31D4

Step 6: Make Your Dice Ready to Use

Picture of Make Your Dice Ready to Use

Make a cubic cover for your dice and put the board into it. I used a dark plastic sheet that LEDs light could pass through it.
Now put the battery into the dice, place it on the ground, and tap on its head to roll.
The dice will be turned off automatically after about a minute.

Step 7: Let's Take a Look at the Code

I wrote the program with OshonSoft PIC Simulator IDE basic.
Here's the code:

INTCON = %10001000 'Watch for port change interrupt
OPTION_REG = %11000111 'Enable timer0 with 1:256 prescalar
GPIO = 0 'Turn off all LEDs
TRISIO = %101000 'GP3 and GP5 are input other are output
IOC = %100000 'Watch for GP5 change
Dim number As Byte
Dim ledoff As Word
Dim gpioval As Byte
End 'Go to low power mode
On Interrupt
Save System
If INTCON.GPIF = %1 Then 'If button is pressed
If GP5 = %0 Then
GPIO = 0
number = TMR0 Mod 6 + 1 'make a random number according to timer0
If number = 1 Then gpioval = %000001
If number = 2 Then gpioval = %010000
If number = 3 Then gpioval = %010001
If number = 4 Then gpioval = %010100
If number = 5 Then gpioval = %010101
If number = 6 Then gpioval = %010110
ledoff = 0 'turn off all LEDs for a moment
If INTCON.T0IF = %1 Then 'timer0 interrupt
ledoff = ledoff + 1
If ledoff = 1000 Then 'turn off all LEDs after about a minute
GPIO = 0
ledoff = 0
If ledoff = 15 Then GPIO = gpioval 'display the number


omnibot (author)2011-08-23

Cool job! I especially like the DIY coincell holder on the bottom, I am SO gonna copy that for my own projects.

farzadbayan (author)2011-08-13

Good Job Vahid! :))

artworker (author)2011-06-20

Man! very beautiful! Get a mac style casing designed and market it! The circuit is perfect!

vahidyou (author)artworker2011-06-21


Bongmaster (author)2011-06-19

looks kool, how about encasing it in resin, but somehow leave a hole for battery access and roll button?

vahidyou (author)Bongmaster2011-06-19

Yes, and at last the dice looks nicer.

davemmanc (author)2011-06-19

You could try switching to smt parts and get it closer to dice size.

vahidyou (author)davemmanc2011-06-19

Good idea

About This Instructable



Bio: I'm a mechanical engineer, and I like computer programming, mechanics, electronics and specially the robotics.
More by vahidyou:Serial Port Over WiFiCheap Logic AnalyzerCheap STK500 AVR programmer for Atmel Studio
Add instructable to: