BuseKoroglu
Published

Yücel Boru Fen Lisesi Performans Ödevi

LED Dice with Arduino! In this project, I took ordinary dice up to another level.

IntermediateFull instructions provided612
Yücel Boru Fen Lisesi Performans Ödevi

Things used in this project

Hardware components

Jumper wires (generic)
Jumper wires (generic)
×16
5 mm LED: Red
5 mm LED: Red
×7
Arduino UNO
Arduino UNO
×1
Resistor 330 ohm
Resistor 330 ohm
×8
SparkFun Solder-able Breadboard - Mini
SparkFun Solder-able Breadboard - Mini
×1
Switch Actuator, Head for spring return push-button
Switch Actuator, Head for spring return push-button
×1

Software apps and online services

Arduino IDE
Arduino IDE

Story

Read more

Schematics

HOW MY CIRCUIT LOOKS LIKE ON TINKERCAD

I made my Led Dice project on Tinkercad.

Code

THE CODES THAT I USED FOR THIS PROJECT

Java
These are the codes that are in my project. If you want to add new parts to your project, you have to add those codes on your own.
int pinLeds1 = 2;
int pinLeds2 = 3;
int pinLeds3 = 4;
int pinLeds4 = 5;
int pinLeds5 = 6;
int pinLeds6 = 7;
int pinLeds7 = 8;

int buttonPin = 13;
int buttonState;
long ran;
int time = 2000;

void setup() {
  pinMode (pinLeds1, OUTPUT);
  pinMode (pinLeds2, OUTPUT);
  pinMode (pinLeds3, OUTPUT);
  pinMode (pinLeds4, OUTPUT);
  pinMode (pinLeds5, OUTPUT);
  pinMode (pinLeds6, OUTPUT);
  pinMode (pinLeds7, OUTPUT);
  pinMode (buttonPin, INPUT);
  randomSeed(analogRead(0));
  Serial.begin(9600);

}

void loop() {
  buttonState = digitalRead(buttonPin);
  if (buttonState == HIGH){
    ran = random(1, 7);
    if (ran == 1){
      digitalWrite (pinLeds4, HIGH);
      delay (time);
      Serial.println(1);
    }
    if (ran == 2){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds7, HIGH);
      delay (time);
      Serial.println(2);
    }
    if (ran == 3){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds4, HIGH);
      digitalWrite (pinLeds7, HIGH);
      delay (time);
      Serial.println(3);
    }
    if (ran == 4){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds6, HIGH);
      digitalWrite (pinLeds7, HIGH);
      delay (time);
      Serial.println(4);
    }
    if (ran == 5){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds6, HIGH);
      digitalWrite (pinLeds7, HIGH);
      digitalWrite (pinLeds4, HIGH);
      delay (time);
      Serial.println(5);
   }
   if (ran == 6){
      digitalWrite (pinLeds1, HIGH);
      digitalWrite (pinLeds2, HIGH);
      digitalWrite (pinLeds3, HIGH);
      digitalWrite (pinLeds5, HIGH);
      digitalWrite (pinLeds6, HIGH);
      digitalWrite (pinLeds7, HIGH);
      delay (time);
      Serial.println(6);
   }
  }
  digitalWrite (pinLeds1, LOW);
  digitalWrite (pinLeds2, LOW);
  digitalWrite (pinLeds3, LOW);
  digitalWrite (pinLeds4, LOW);
  digitalWrite (pinLeds5, LOW);
  digitalWrite (pinLeds6, LOW);
  digitalWrite (pinLeds7, LOW);
  
  

}

Credits

BuseKoroglu

BuseKoroglu

1 project • 0 followers

Comments