Project showcase
Digital Dice

Digital Dice

Create digital dice in 15 minutes!

  • 1,598 views
  • 0 comments
  • 0 respects

Components and supplies

About this project

This project is a simple "dice" project for beginners! Here you can find a video from 1NTERGALACTIC on YouTube:

Presentation video from 1NTERGALACTIC

Code

CodeArduino
int l1 = 2;
int l2 = 3;
int l3 = 4;
int l4 = 5;
int l5 = 6;
int l6 = 7;
int l7 = 8;
int b = 10;
long ran;

void setup() 
{
  pinMode(l1, OUTPUT);
  pinMode(l2, OUTPUT);
  pinMode(l3, OUTPUT);
  pinMode(l4, OUTPUT);
  pinMode(l5, OUTPUT);
  pinMode(l6, OUTPUT);
  pinMode(l7, OUTPUT);
  pinMode(b, INPUT_PULLUP);  
  Serial.begin(9600);
  Serial.println("----------------------------------------------");
  Serial.println("---------------De numerique 2.0---------------");
  Serial.println("----------------------------------------------");
}

void loop() 
{
  if (digitalRead(b) == LOW)
  {
    ran = random(1,7);
    if(ran == 1) {
      digitalWrite(l4, HIGH);
      Serial.print("1, ");
      delay(3000);
    }
    if(ran == 2) {
     digitalWrite(l3, HIGH);
     digitalWrite(l5, HIGH);
     Serial.print("2, ");
     delay(3000); 
    }
    if(ran == 3) {
     digitalWrite(l3, HIGH);
     digitalWrite(l4, HIGH);
     digitalWrite(l5, HIGH);
     Serial.print("3, ");
     delay(3000); 
    }
    if(ran == 4) {
     digitalWrite(l1, HIGH);
     digitalWrite(l3, HIGH);
     digitalWrite(l5, HIGH);
     digitalWrite(l7, HIGH);
     Serial.print("4, ");
     delay(3000); 
    }
    if(ran == 5) {
     digitalWrite(l4, HIGH);
     digitalWrite(l1, HIGH);
     digitalWrite(l3, HIGH);
     digitalWrite(l5, HIGH);
     digitalWrite(l7, HIGH);
     Serial.print("5, ");
     delay(3000); 
    }
    if(ran == 6) {
     digitalWrite(l1, HIGH);
     digitalWrite(l2, HIGH);
     digitalWrite(l3, HIGH);
     digitalWrite(l5, HIGH);
     digitalWrite(l6, HIGH);
     digitalWrite(l7, HIGH);
     Serial.print("6, ");
     delay(3000); 
    }
  }
     digitalWrite(l1, LOW);
     digitalWrite(l2, LOW);
     digitalWrite(l3, LOW);
     digitalWrite(l4, LOW);
     digitalWrite(l5, LOW);
     digitalWrite(l6, LOW);
     digitalWrite(l7, LOW);
}

Schematics

Schéma
Capture decran 2017 02 04 a 13 c9goniivaq

Comments

Similar projects you might like

LED Dice

Project showcase by EvdS

  • 14,276 views
  • 11 comments
  • 49 respects

Arduino Digital Dice

Project tutorial by xXarduino_11Xx

  • 1,041 views
  • 5 comments
  • 8 respects

MicroView Digital Dice

Project tutorial by Giovanni Gentile

  • 694 views
  • 1 comment
  • 2 respects

LED Dice

Project showcase by ONYX

  • 8,255 views
  • 1 comment
  • 18 respects

Settlers Of Catan Dice

Project tutorial by joshi

  • 5,945 views
  • 13 comments
  • 28 respects

Simple Arduino Digital Clock Without RTC

Project in progress by Annlee Fores

  • 96,193 views
  • 23 comments
  • 80 respects
Add projectSign up / Login