making Digital Dice using Arduino for Kniffel game

Description:

Digital Dice using Arduino- in this article, I am going to show you how to make a simple digital dice for kniffel game

Digital Dice using Arduino:

In the last articles, you already have some programming basics of the Arduino board. You will of course suspect or hope that this cannot be all, and therefore we will be based on a couple of interesting circuits that apply, deepen and expand our knowledge. It is always exciting to build an Arduino digital dice. A few years ago, when microprocessors didn’t exist or were unaffordable, you have the circuit with several integrated circuits, also called ICs. On the Internet, there are countless handicraft instructions for this. We want the digital dice alone with the Arduino board head. Everyone knows at least one game of dice, be it Kniffel. We want digital dice with our next circuit realized. It consists of a display unit made up of 7 LEDs and a button that starts the dice is composed.

First of all, I’ll show you the arrangement of the LEDs that make up the Points of a real dice is modeled, with the individual points are numbered so that we can the overview later when controlling the individual LEDs keep. The led 1 is in the top left corner and the numbering is then down and then after right until you finally come to led 7 on the far right ends below.

Digital Dice numbers pattern:

For number one all LEDs will be low except led number4

For number two led1 and led7 will be high.

For number three led2, led4 and led7 will be high.

For number four led1, led3,led5, and led7 will be high.

For number five led1, led3, led4,led5, and led7 will be high.

For number six led1, led2,led3,led5, led6, and led7 will be high.

Components Required for Digital Dice:

For this example, we need the following components:

• Seven red LEDs
• Seven 330 ohm resistors
• One 10k resistor
• One button
• Jumper wires

Arduino Uno:

Mega 2560:

330-ohm resistors pack:

Jumper Wires:

Variable Supply:

Digital Multimeter:

Vero Board / stripboard:

Soldering iron kit:

Solder wire:

digital dice Circuit diagram:

The circuit diagram shows us the 7 dice LEDs with their 330 ohms Series resistors and the dice button with its pull-down Resistance.

Digital dice Arduino program:

Here is the sketch code for controlling the Arduino digital dice:

Program explanation:

The first value [6] in the pair of square brackets indicates the number of Rows, the second [7] that of the columns. Access to an item is also done using the double pair of brackets:

digits [row] [column]

The setup function takes over the task again the initialization of the individual pins:

The pins for controlling the LEDs were also put into an array which is programmed as OUTPUT in the setup function. Only the button that is connected to a digital input a normal variable is assigned. The Â main task is again taken over by the loop function:

When the button has been pressed, the function GenrateDigits will be called. It takes a random value between 1 and 6 passed. The working of the function, we should a little inspect. It actually only consists of a for loop() that controls the individual LEDs for a number that is rolled. Let’s assume that a 4 was rolled, with the Function this value is supplied as an argument. Now begins for loop with their work. It controls the pins and determines the required HIGH / LOW level for the respective LED: