radekw8733
Published © LGPL

LED Dice

A very easy project with my library.

BeginnerShowcase (no instructions)5,550
LED Dice

Things used in this project

Hardware components

Arduino UNO
Arduino UNO
Any arduino wil be fine
×1
Jumper wires (generic)
Jumper wires (generic)
Need 10-20 wires
×1
Resistor 221 ohm
Resistor 221 ohm
×1
LED (generic)
LED (generic)
×7

Story

Read more

Schematics

Schematic

Other leds connect like in schematic

Code

Dice.ino

C/C++
#include <DiceController.h> // Including our library

Dice dice(2,3,4,5,6,7,8,9,10); // Led configuration

int repeats; // Setting variable for repeats

void setup() {
  pinMode(A0,INPUT); // Configuring button
}

void loop() {
  repeats = 0; // Reseting repeats
  if (analogRead(A0) == 1023) {
    while (repeats < 4) {
      int selectedNumber = random(1,6); // Randoming number
      dice.setNumber(selectedNumber); // Setting randomed number
      repeats++; // Increasing variable for repeat
      delay(100); // Delay for good visibility
    }
  }
}

Credits

radekw8733
0 projects • 4 followers

Comments