“You dont need anyone’s permission to create something great.” -Massimo Banzi, cofounder of Arduino.

Who doesn’t love making leds turn on, it is the foundation of electronics!

Hello, and welcome to today’s project tutorial! This was actually the first mini project I worked on upon buying my arduino starter kit eons ago. I used this die as a way for me and my partner to decide what to do for food. We would assign different numbers for different options, between 1-6, and then “roll” the die. Whatever the number, we would do that option , for example pizza. Mmmm pizza….(pizza was heavily weighted using this system).

By the end of the tutorial you will hopefully be able to set up an arduino die, and in doing so, will learn about electronics, code and some problem solving skills. So lets begin!

Parts needed

7 x led (choose any colour, or multiple colours, I have went with blue)

7 x 100 ohm resistors*

1 x button/tactile switch

1 x arduino

Jumper wires

Breadboard

*See below for more information on resistor values needed.

Link for an electronics components kit, which comes with leds, wires, resistors and a few more neat little items.

Fritzing diagram

Connections –

Top left led connects to digital pin 5

Middle left led connects to digital pin 6

Bottom left led connects to digital pin 7

Bottom right led connects to digital pin 8

Middle right led connects to digital pin 9

Top right led connects to digital pin 10

Centre led connects to digital pin 11

Step 1 – Button and Power

Start by connecting a jumper wire between 5V from the arduino and your power rail, and Ground from the arduino to the other power rail

Connect the four legs of the button over the bridge of the breadboard. A button works under the principle that when it isn’t pressed, the signal goes through one pin, and flows to the pin opposite on the other side. When pressed, the conductive tracks of the switch move, and the signal will flow out of the other pin on the same side as the signal coming in. Because of this, connect a wire from your power rail into one pin of the switch, and on the other pin of the switch on the same side, connect your signal wire, connecting to digital pin 2.

Step 2 – Connect those leds!

Connect 3 leds down either side, so that their short legs (negative/cathode) is connected to the negative power rail. Connect their longer legs (positive/anode) into their own row on the board, making sure to leave room for resistors. Add a jumper wire from the ground rail to the other ground rail to have them connected down both sides. For the centre led, straddle it over the bridge, with a leg in its own row on either side. Connect a jumper wire from ground to the short leg of the centre led.

The leds should look like die, with a middle led, which will be used for the numbers 1, 3 and 5.

Step 3 – Add the resistors

For the next part, we need something to protect our leds. To do this, we will place a resistor in series with the led. Different coloured leds need different values of resistance to not burn out. To determine the value of your resistor needed if you are using different colours, you can use this handy website!

Connect the resistor into same row that that the long legs of the leds are connected, with the other end of the resistor going in to their own new row.

Step 4 – Connecting leds to the arduino, upload code

For the final step, connect a wire from the row that the end of the resistor is in, to the respective digital pin, following the pin layout

Top left led connects to digital pin 5

Middle left led connects to digital pin 6

Bottom left led connects to digital pin 7

Bottom right led connects to digital pin 8

Middle right led connects to digital pin 9

Top right led connects to digital pin 10

Centre led connects to digital pin 11

Once all leds are connected, upload the code found here. Copy and paste the code into the arduino IDE.

Once loaded, check to make sure it is working. Once the button is pressed, you should see the leds skip through different values, finishing on the end number. Then flashing this number before staying on.

Common problems and future improvements

If no leds turn on, ensure the leds are wired to the correct digital pins. Also, check to make sure the legs of the leds are the correct way round. Also check over your wiring, to make sure the components in series go into the correct rows, as they might be in the row just next to the correct one. Check to make sure components aren’t touching, such as the resistor legs.

I have commented the code so that you will be able to follow along. For fun, try analysing the code, and replicating certain parts of it if you haven’t before, such as the arrays and randomSeed function. Arrays and for loops are an integral way to shorten code, and will be used in many of my future tutorials.

Feel free to look through my other tutorials for inspiration for your next project.

Thank you for reading, hope it helped.

EngineerGeek