Englishscone
Published © GPL3+

Dicey

Easy Arduino dice project, great for beginners learning how to create homemade functions.

BeginnerProtip3,517
Dicey

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×14
Resistor 221 ohm
Resistor 221 ohm
×6
Breadboard (generic)
Breadboard (generic)
×1
Arduino UNO & Genuino UNO
Arduino UNO & Genuino UNO
×1
LED (generic)
LED (generic)
×6

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

Diagram

Code

dicey.ino

C/C++
int onePin = 1;
int twoPin = 2;
int threePin = 3;
int fourPin = 4;
int fivePin = 5;
int sixPin = 6;           //six leds connected with 220 ohm resistors
void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
randomSeed(analogRead(0));
pinMode(onePin,OUTPUT);
pinMode(twoPin,OUTPUT);
pinMode(threePin,OUTPUT);
pinMode(fourPin,OUTPUT);
pinMode(fivePin,OUTPUT);
pinMode(sixPin,OUTPUT);
}

void loop() {
int number = random(1,7);  //find random number and do void 1,6 accordingly
if (number==1)
 one();
else if(number==2)
 two();
else if (number==3)
 three();
else if (number==4)
 four();
else if (number==5)
 five();
else if (number==6)
 six();
}
void one()
  {
  Serial.println("one");       //Serial monitor also runs for viewing
  digitalWrite(onePin,HIGH);
  delay(50000);
  digitalWrite(onePin,LOW);
  delay(1000);
  }
void two()
  {
  Serial.println("two");
  digitalWrite(onePin,HIGH);
  digitalWrite(twoPin,HIGH);
  delay(50000);
  digitalWrite(onePin,LOW);
  digitalWrite(twoPin,LOW);
  delay(1000);
  }
void three()
  {
  Serial.println("three");
  digitalWrite(onePin,HIGH);
  digitalWrite(twoPin,HIGH);
  digitalWrite(threePin,HIGH);
  delay(50000);
  digitalWrite(onePin,LOW);
  digitalWrite(twoPin,LOW);
  digitalWrite(threePin,LOW);
  delay(1000);
  }
void four()
  {
  Serial.println("four");
  digitalWrite(onePin,HIGH);
  digitalWrite(twoPin,HIGH);
  digitalWrite(threePin,HIGH);
  digitalWrite(fourPin,HIGH);
  delay(50000);
  digitalWrite(onePin,LOW);
  digitalWrite(twoPin,LOW);
  digitalWrite(threePin,LOW);
  digitalWrite(fourPin,LOW);
  delay(1000);
  }
void five()
  {
  Serial.println("five");
  digitalWrite(onePin,HIGH);
  digitalWrite(twoPin,HIGH);
  digitalWrite(threePin,HIGH);
  digitalWrite(fourPin,HIGH);
  digitalWrite(fivePin,HIGH);
  delay(50000);
  digitalWrite(onePin,LOW);
  digitalWrite(twoPin,LOW);
  digitalWrite(threePin,LOW);
  digitalWrite(fourPin,LOW);
  digitalWrite(fivePin,LOW);
  delay(1000);
  }
void six()
  {
  Serial.println("six");
  digitalWrite(onePin,HIGH);
  digitalWrite(twoPin,HIGH);
  digitalWrite(threePin,HIGH);
  digitalWrite(fourPin,HIGH);
  digitalWrite(fivePin,HIGH);
  digitalWrite(sixPin,HIGH);
  delay(50000);
  digitalWrite(onePin,LOW);
  digitalWrite(twoPin,LOW);
  digitalWrite(threePin,LOW);
  digitalWrite(fourPin,LOW);
  digitalWrite(fivePin,LOW);
  digitalWrite(sixPin,LOW);
  delay(1000);
  }

Credits

Englishscone

Englishscone

4 projects • 2 followers
Skills in Arduino, hardware dev, python. Help on anything I can help with, just ask.

Comments