Here is our latest ‘easy build’ kit. Designed for beginners, the Dice Kit comes with everything you need to make your own ‘Electronic Die’. The name Dice kit sounds a great deal better than ‘Die Kit’, so we bent english grammar rules just a little in the name of making a marketable product.
Tap the DK on the table, and the LEDs light up and show a number from 1 through 6. After a short while, the DK goes into sleep mode, until the next time it is tapped. We have experimented with battery life, and even the oldest CR2032 battery that we had laying around the workbench, and used in other projects is still running in our production prototype.
Why 7 LEDs for only 6 numbers? We have heard that a few times. Because we wanted to make the DK as realistic as possible, we needed the middle LED, as it is used in 1,3,5.
Now the more interesting, answer to your question...
The principle is rather simple.
When you roll a regular Die on the table, it spins and lands with a top side, using the inertia from the the person throwing or dropping it to randomize a result from 1 to 6. We know there are people out there with talents for ‘loading dice’... Well they will have some difficulty loading these. Unless they have an aptitude for assembly language, and reprogram the code on the PIC chip.
For the record, SpikenzieLabs does not condone gambling. However we do think you’d be the coolest cat on the block if you showed up to a game of marbles with one of these.
The DK ‘reads’ the impact using the piezo sensor that you will be gluing to the bottom acrylic base.
This sensor reading enters the PCB as analog voltage. A short burst of energy that passes through a voltage limiting, and direction setting Diode (D1). The Diode protects the somewhat sensitive PIC chip from an over voltage.
This reading, or we can call it a ‘Signal’ is read by the PIC on one of the 8 Legs. The reading is analog, the chip converts this analog information into a decimal value.
For Example, : If the piezo sends 1.22348 volts into the PIC, it is interpreted as ‘1.22348’ volts. In order to obtain a random result between 1 and 6, we have developed a way of converting results to 1-6 by a reading from the least significant decimal place, we use that information to generate the associated number on the face of the DK.
The 10mm chunky LEDs are connected through resistors to the PIC chip, and light up the result. In fact the LEDs are actually flashing on and off. The PIC found on the DK, has a limited number of pins, so the seven LEDs are controlled by four pins. After a pause of about 15 seconds, the PIC enters sleep mode, and turns off the LEDs.
In sleep mode, the PIC is in a very low power mode. The instant the DK is struck, the piezo sends a pulse that immediately wakes up the PIC, and starts running the program once again.
Note: If you are new to soldering, we strongly recommend watching our build video. We produced this video to help people who are new to soldering, and kit assembly. We kept it short, and we recommend watching it & pausing while you are building the DK.
You are going to start the build with the resistors.
In the kit, you have 4 x 470ohm resistors, 1 x 10k resistor, and 1 x 1M resistor. Resistor values for this type of resistors are encoded using the color bands around their bodies. There are ‘ resistor decoders ’ out on the internet. To make decoding them easier, here are some simple illustrations that show you which resistor is which.
1 Meg Ohm
Resister illustrations from Sam Engström’s web page: samengstrom.com
Separate the resistors from the packing tape. Hint: If you clip the resistors from the packing tape leave the resistor legs as long as possible, it will make installation easier.
Now that you have a bunch of loose resistors, we are going to bend the legs for installation into the PCB.
Starting first with the 470 Ohm resistors. (This is the resistor value for the RED and GREEN Dice Kits)
On the new Dice Kit with BLUE LEDs we are using 330 ohm resistors for resistors R1,R2,R3, and R4.
Holding the resistors as you see in the photo below, bend the legs at 90 degree angles to the body of the resistor. The holes on the PCB are designed to accept the resistors in this way.
One at a time, put the 4x470 Ohm resistors into positions R1,R2,R3, and R4. Direction for these does not matter. We find that they look a little prettier when they are all going in the same direction..
After each resistor is put in place, ensure that the body of the resistor is flush with the PCB. You can temporarily lock the resistor in place by putting a slight bend on the bottom side : (See Photo), alternatively, you can put a piece of masking tape against the body of the resistor to keep it in place while you flip the PCB over and solder the legs.
If you have never soldered before, you may want to watch our build video. Soldering is easy, and you will get better at it every time you do it. Building little electronic kits like these is the best way to perfect your soldering skills.
Solder each resistor as you go, and check to be sure that each one is flush with the PCB.
Trim the excess resistor leg off as flush as possible with the bottom of the PCB,
Using the same method, Solder Resistor 1meg ohm into position R5, and 10K ohm into position R6.
Prep the resistors by using your fingers to bend their legs like this.
In order to hold parts in the PCB before they are soldered in place, you can bend the legs a little like this or use masking tape.
Now we will move onto the installation of the Diode D1. Bend the legs on the diode in the same way that you prepared the resistors. This diode is really small, hold it between your fingers. Using a pair of needle nose pliers is tempting, as diodes are very fragile, it is not recommended.
Diodes are directional. The notch on the D1 illustration on the PCB has to match up with the black band on the end of the diode. (SEE PHOTO)
Solder and trim the excess leg in the same way as you did for the resistors, making sure that the diode is flush with the surface of the PCB.
It is very important that the Diode be installed in the correct orientation. The black line on the diode must line us with the white line printed onto the PCB. (We make this photo big so that it would be easier to see.) Note: unlike this photo, you would push the diode flush with the PCB before you soldered it.
Now, we will install most of the LEDs.
Some things to note, and this is crucial. LEDs are ‘directional’ and their ‘polarity’ matters. Much like a Diode, LEDs are ‘Light Emitting Diodes’ so, they have to be installed in a particular direction.
Notice (PHOTO) how one of the legs on each LED is about 1/8” longer than the other? The longer leg is (+) positive. The longer leg has to be installed in the corresponding (+) hole in the PCB, the shorter leg goes into the other hole. If you make a mistake... the DK will not work. An easy way to remember this rule, is to say to yourself, “I am positive that this leg is longer”, and you should have great success. As a rule of thumb, if one leg is longer than the other, there is a polarity to consider.
Insert the LEDs one at a time, and solder them to the PCB. Exclude the LED whose placement is to the left of the word PIEZO (SEE Photo) this LED will be installed as the last step in this build. This is to make it easier to solder the battery holder.
You can hold the LED flush to the PCB with your finger, and use a set of ‘Helping Hands’ to hold your solder. It is a bit of a juggling game, but once you become comfortable using the ‘Helping Hands’ you will find them indispensable.
Limit the amount of time that you have the soldering iron touched to the legs of the LEDs. You can burn them up if you overheat them. You shouldn’t need more than about 1-2 seconds of contact to melt the solder, and make the connection. If you see that you need longer, let the area cool down, and come back to it later.
Trim the legs as you go, once again, as flush as possible to the surface of the PCB. WEAR EYE PROTECTION. These legs have a tendency to go flying in unpredictable directions. You can also hold the leg that you are snipping with your other hand. It is possible to hit someone across the room with one of these flying legs, so please be careful.
Now that all but one of the LEDs is installed, it is time to insert and solder the PIC chip.
Important: Note that one of the two LED legs is longer than the other. This longer leg goes into the pin hole marked with the “+”.
It will not work if installed backwards!
Note: Do not solder this LED at this time, this makes it easier to solder the battery holder.
Remove the PIC from the antistatic foam, and place it onto the PCB. Direction matters here as well. You want to match up the notch on the PIC chip to the notch on the white printing of the PCB. (see photo)
Carefully hold the PIC chip in place, as you solder the first leg on one end to the last leg on the other end. Once you have these legs securely soldered in place, verify that the PIC chip is flush with the PCB, and then solder the remaining legs. (see photo)
Take your time setting it in place. Make sure that the chip gets installed flush with the PCB and double check to make sure the notch and notch marking match up. When you are soldering this chip, be mindful to not overheat the chip with an exaggerated amount of soldering iron contact.
Be careful, if you are holding the chip onto the PCB with your finger, you could get burnt because the metal legs that you are soldering could touch your finger.
Even though the excess leg on a chip is very short, trim even the tiniest amount that may be still poking through. This will help with the placement of the battery holder in the next step.
When inserting the PIC chip onto the Dice Kit PCB, make sure that the notch in the chip matches the notch printed on the white silk screen.
(Other parts are omitted in the photo for clarity.)
NOTE : Before soldering the battery holder you must have all of the other parts soldered with the exception of the last LED and the Piezo.
The supplied battery holder has a bit of a notch on one end of it. Match the orientation, to the design printed on the bottom side of the PCB. Make sure that the two legs of the battery holder go through to the top side of the PCB. If they don’t make it, you may need to trim some of the resistor, and LED legs a little closer.
There should be a somewhat even gap beneath the battery holder, and the legs should still make it all the way through to the top side of the PCB.
Most beginner kits would not expect you to be soldering on both sides of a PCB. We decided that with proper instruction, everyone can build this kit.
You can hold the battery holder to the bottom side of the PCB using a bit of tape. Then put the DK down on top of the battery holder, and solder the battery holder legs from the top. If you’re considering just holding it in with your finger, don’t! There is an obvious finger burn potential here, as you would possibly be touching the same piece of metal that your iron is touching.
Take extreme care when you are soldering the battery holder to not touch any of the LEDs with the hot iron. Burning into the LED could easily damage that LED at worst, and at best, leave it with a nasty groove. If you’re new to soldering, re-watch our build video, and just go slow and steady
This is how the battery holder is inserted from the bottom of the PCB. (Other parts omitted from the photo for clarity.)
The two red circles on this photo show the two leads from the battery holder, that get soldered from the top of the PCB.
Note: That the LED in the bottom left hand side of this photo has not been installed yet. By soldering it last it is easier to get to the smaller battery lead, without touching the LED with your soldering iron.
Now that the battery holder is installed, you can install the remaining LED. Keep in mind the motto “I am positive this leg is longer.”
Insert, solder, and trim the legs.
We are almost done. The last component that we have to solder is the Piezo.
The piezo that is supplied has two wires already soldered to the body of the piezo. These wires are really thin, and very flexible. Send the wires up through the bottom of the PCB one at a time. We have found that holding the wire in place with a small piece of tape works best.
Adjust the amount of wire that is poking through the top so that the end of the wire is flush with the top surface of the PCB. Too much wire poking through, and the plastic coating on the wires will insulate the piezo from having a connection to the PCB. Take time to ensure the ideal amount of wire is sent through before you solder these wires to the PCB.
The Black wire goes through the [B] hole, and the red wire through the [R] hole.
Note: once the piezo is soldered, you will want to handle the PCB and Piezo with great care. Try not to stress these wires, they are very thin, and you really do not want them to come loose from the Piezo. Soldering on a piezo disc is not easy, as the peizo itself makes for a great heat-sink, and is difficult to heat up with your soldering iron.
The piezo sensor is soldered into the holes marked PIEZO with the red wire in the “R” and the black wire in the “B” hole.
Bottom view with the piezo soldered in place.
Now that the soldering is complete, it is time to prepare the laser cut acrylic base. We recommend a hands washing, and a clean work surface for this portion of the build.
Peel the protective plastic from the acrylic pieces. You have before you one base that is tapped to accept the supplied screws. Have an appropriate phillips driver handy. (its the X head screwdriver for those of you that were unaware it is called a ‘phillips’) Also there are three identical side pieces, and one special side piece with a cut groove between the two screw holes. This indentation in the plastic goes up against the bottom of the PCB and allows the wires for the piezo to be routed towards the middle of the PCB unencumbered. If the groove is not deep enough for your wires, use a small file or sand paper to make it a bit deeper.
Notch for the piezo wire.
Install the battery into the battery holder, and test to make sure that you’re getting some LED lighting action on the Dice Kit. Take special care to not allow the piezo to come in contact with the PCB. The piezo is metallic, and could possibly cause a short if it contacts the solder points on the PCB.
Start the battery like this.
Press until it clicks into place.
The piezo is really sensitive so don’t be surprised if just dragging it across the table causes the lights to flash. We have calibrated the sensitivity to be ideal when the Piezo is glued to the acrylic base.
If you don’t have any lights flashing, there is something wrong. Remove the battery, and verify your solder joints. Ask an experienced friend to have a look, and correct your mistakes, or re-watch our build video and try to determine where you went wrong.
Stack the side pieces on top of the base and then place the PCB on top.
Insert the screws through the PCB. A bit of wiggling may be needed to line all the parts up.
Using a tiny amount of the adhesive of your choice, attach the piezo to the base piece of plastic. We have found that a tiny bit of epoxy, contact cement, or construction adhesive works best. A light sanding of the center of the base where the piezo is to be glued can help the adhesion. Hot glue didn’t yield the best results in the lab.
Press the piezo firmly, and wait for the glue to setup. Read the recommended setup time on the label of your adhesive. If some adhesive squirts out from under the piezo, leave it alone. You will not be able to wipe against the acrylic base without really messing up the clear acrylic. You are better off leaving the natural excess around the piezo.
Once your adhesive has setup, line up the sides, and put the screws through the top of the PCB. Keep in mind the special piece that gets installed ‘etched side up’ with the piezo wires.
Try to install the PCB so that the piezo wires remain as close to the inside of the DK as possible. Sometimes rotating the bottom plastic a half turn will be enough to pull them into the center of the DK. Do not stress the wires.
Tighten the screws finger tight only. Once the screws are in, you’re finished. Tap the DK on the table, and let the dice games begin!
For those of you that want to know more about how the Dice Kit works here is a more detailed explanation.
One of the challenges in developing the Dice Kit was getting seven LEDs lit with very few pins on the PIC chip.
After examining how a real die works, I noticed that all six possible throws are produced with a combination of only four dot patterns.
The PIC can manipulate it’s pins pins to be either inputs (no effect on the outside world, called Hi-Z ), or outputs with a high or low value. With all of these possibilities and by driving two LEDs per pin (except the center LED) only four pins were needed to make the four patterns.
Now that the dice was working I was still not happy with the results. There was a problem because some of the LEDs were much brighter than the others.
After examining the patterns required to make the LEDs show the different die throws, I noticed that some results required only one pattern and some required up to three different patterns. This was the reason that some LEDs where brighter than other; they were simply lit for a longer time!
The solution to this was to make a programming loop where all of the die throws display in a sequence of three steps (the maximum steps required for a “six”). After playing with the delay in the the programming loop, I settled on a delay of around 20ms of lit time per step.
The results were great. Now if the throw is a one, or a six (or any other result) the LEDs are only lit for ~20ms each. This gives a nice even glow, without any flickering.
While designing the Dice Kit, I really didn’t want to have a power switch. Not only would people forget it on and drain the battery, but I felt it would take away from the aesthetic appeal of the Dice Kit.
The PIC used in the Dice KIt is the 12F675, it has both the capacity to read analog values (used to read the piezo) and is also able to go into a very low power sleep mode.
To make the PIC sleep is very easy, simply give it the sleep command. In the Dice Kit I used a timer, when the timer runs out, the Dice Kit goes to sleep (about 15 seconds). It is set to reset the timer every time the Dice Kit senses a tap, this way it won’t go to sleep while you are playing with it.
Getting it to wake from sleep was a bit more difficult. There are many ways to get a PIC to wake up, but in this case I only wanted it to wake from a piezo sensed tap.
In order to do this, the same pin that is used to sense the analog piezo hit could be used ... but! To wake the PIC from sleep using this pin the PIC has to be told to cause an “interrupt from a change” on that pin. Also, the change on pin interrupt doesn’t work while the pin is used for analog input. So, after the timer runs out and the PIC is about to go to sleep, the program changes the pin to a digital pin and activates the interrupt on change function of that pin.
Now, while the PIC is sleeping, if the pin senses a change (because someone taped the Dice Kit), the PIC wakes up and immediately goes into the interrupt routine where it changes the pin back into an analog pin and reads the piezo value.
When the PIC reads an analog value it returns a 10 bit value which represents a decimal value from 0 to 1023. The Dice Kit uses only the last three bits, which is a decimal value from 0 to 7. In order to “filter” these value into a 1 to 6 result the bits are shifted to the left. Giving a result from 1 to 6, plus possibly a zero. Test is done for a zero, and if it is zero the analog value is rejected and reread. Once a good value is found, it is displayed on the LEDs.
In the interest of keeping things random, the Dice Kit does not do any checking to see if the same values have come up previously. So, sometimes it may display the same value twice.
Dice Kit Schematic.
Copyright SpikenzieLabs 2019