Modern Dice

by vahidyou in Living > Toys & Games

5268 Views, 16 Favorites, 0 Comments

Modern Dice

DiceP.JPG
Dice.JPG
In the dark.JPG
Dice1.JPG
Dice2.JPG
Dice3.JPG
Dice4.JPG
Dice5.JPG
Dice6.JPG
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.

What You Need

Things needed.JPG
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)

Making the PCB

PCB.png
IMG_5501.JPG
Board After Soaking in Acid.JPG
Placing Printed Circuit on the Board.JPG
IMG_5502.JPG
Board After Ironing.JPG
IMG_5505.JPG
Drilling Circuit Board Holes.JPG
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.

Soldering Components

Dice.png
PCB.png
470Ohm Resistors.png
IC.png
LEDs.png
10K Resistor.png
Button.png
Battery.png
Button & 10K resistor.JPG
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.

Attaching the Battery Holder

Button & 10K resistor.JPG
Battery holder on the Button.JPG
Battery holder attachment 1.JPG
Battery holder attachment 2.JPG
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.

Programming

PIC12F675.JPG
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

Downloads

Make Your Dice Ready to Use

Side1.JPG
Side4.JPG
Side3.JPG
Side2.JPG
Battery holder.JPG
Battery.JPG
Dice.JPG
DiceP.JPG
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.

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
INTCON.T0IE = %1
Endif
INTCON.GPIF = %0
Endif
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
INTCON.T0IE = %0
Endif
If ledoff = 15 Then GPIO = gpioval 'display the number
INTCON.T0IF = %0
Endif
Resume        

Downloads