Devices & Components
Arduino Uno Rev3
Jumper wires (generic)
Resistor 221 ohm
LED (generic)
Project description
Code
Dice.ino
c_cpp
1#include <DiceController.h> // Including our library 2 3Dice dice(2,3,4,5,6,7,8,9,10); // Led configuration 4 5int repeats; // Setting variable for repeats 6 7void setup() { 8 pinMode(A0,INPUT); // Configuring button 9} 10 11void loop() { 12 repeats = 0; // Reseting repeats 13 if (analogRead(A0) == 1023) { 14 while (repeats < 4) { 15 int selectedNumber = random(1,6); // Randoming number 16 dice.setNumber(selectedNumber); // Setting randomed number 17 repeats++; // Increasing variable for repeat 18 delay(100); // Delay for good visibility 19 } 20 } 21} 22
Downloadable files
Schematic
Other leds connect like in schematic
Schematic
Schematic
Other leds connect like in schematic
Schematic
Comments
Only logged in users can leave comments