Remote-controlled RGB mood light
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Shop by category
Shop all componentsRoll an electronic dice: press a button and a random number from 1 to 6 appears on a 7-segment display, complete with a rolling animation. Each digit is drawn by lighting a particular combination of the seven segments. Those combinations are stored in a two- dimensional array, so showing a number is simply a matter of walking through one row of that array. randomSeed(analogRead(A0)) reads electrical noise from an unconnected analog pin, which gives a different starting point every time the board is powered up, without it, the dice would roll the same sequence after every reset.
Every part for this build comes in the Geekobot Explorer Kit box, a Geekobot exclusive, together with the parts for all 61 projects, from a first blinking LED to a smart fan and a reaction game. The wiring below is the kit's own wiring.
Tick anything you already have and the total updates.
The brain of every Explorer Kit project
Male-to-female and female-to-female leads for the modules
220 ohm resistors: one in series with every LED segment
Nano I/O shield from the kit: every pin has its own S, V, G header, so modules plug in with jumpers
Follow the colours: red is power, dark grey is ground, blue is a signal.
explorer_kit_11_digital_dice.inoVerify & upload in Electrolarkint segPins[7] = {2, 3, 4, 5, 6, 7, 8};
int buttonPin = 9;
// Segment order: a b c d e f g
byte digits[7][7] =
{
{0, 0, 0, 0, 0, 0, 0}, // blank
{0, 1, 1, 0, 0, 0, 0}, // 1
{1, 1, 0, 1, 1, 0, 1}, // 2
{1, 1, 1, 1, 0, 0, 1}, // 3
{0, 1, 1, 0, 0, 1, 1}, // 4
{1, 0, 1, 1, 0, 1, 1}, // 5
{1, 0, 1, 1, 1, 1, 1} // 6
};
void showDigit(int n)
{
for (int i = 0; i < 7; i++)
{
digitalWrite(segPins[i], digits[n][i]);
}
}
void setup()
{
for (int i = 0; i < 7; i++)
{
pinMode(segPins[i], OUTPUT);
}
pinMode(buttonPin, INPUT_PULLUP);
randomSeed(analogRead(A0));
showDigit(0);
}
void loop()
{
if (digitalRead(buttonPin) == LOW)
{
// Rolling animation
for (int i = 0; i < 15; i++)
{
showDigit(random(1, 7));
delay(80);
}
int result = random(1, 7);
showDigit(result);
delay(600);
}
}
Use the kit's mini-USB cable, install the CH340 driver on Windows if no port appears, pick Tools > Board > Arduino Nano and try Tools > Processor > ATmega328P (Old Bootloader) if the upload times out.
The sketch uses INPUT_PULLUP, so one leg goes to the pin and the other to GND. Use two legs on opposite sides of the button.
Check each segment pin against the wiring table. The two middle pins (COM) both go to GND on a common-cathode display.
Each digit is drawn by lighting a particular combination of the seven segments. Those combinations are stored in a two- dimensional array, so showing a number is simply a matter of walking through one row of that array. randomSeed(analogRead(A0)) reads electrical noise from an unconnected analog pin, which gives a different starting point every time the board is powered up, without it, the dice would roll the same sequence after every reset.
Display stays blank until the button is pressed. Numbers flicker rapidly for about one second. A single number between 1 and 6 stays on screen.
Yes. It is project 11 of 61 in the Geekobot Explorer Kit, in level 2 (Displays and games). Every part on the list comes in the kit box, and you can also buy the parts one by one from the list above.
No. Every Explorer Kit project is wired on the Nano I/O shield and the breadboard with jumper wires.
8 parts: Generic Nano CH340 Development Board (Soldered), USB Cable, Solderless Breadboard, Dupont Jumper Wires (40 pcs), Carbon Film Resistor 1/4W 5% (Pack of 10), Tactile Push Button Switch, 7-Segment LED Display 0.56" and Arduino Nano IO Expansion Shield (328P Compatible). On this page you can tick the parts you already have and add only the rest to your cart.
It is a beginner project and takes about 45 minutes. The build on this page has 5 steps.
No. This page has the complete, tested code (explorer_kit_11_digital_dice.ino).
About ₹453 for the parts at the prices on this page. Quantity price breaks lower the cost when you build several.
Random number generation with random() and randomSeed(); 7-segment logic, which segments make which digit; Two-dimensional arrays.
Warm, cool, rainbow or breathing: cycle lighting moods from your sofa.
Press to roll: the pips tumble and slow down before landing on a number.
Wait for the light, hit the button: how many milliseconds can you beat?
A bright 4-digit clock that keeps time through power cuts.
Learning project. Check every circuit and the datasheet of each part before you power it up.