Project tutorial
Arduino Digital Dice

Arduino Digital Dice © GPL3+

An easy and simple way to replace your normal board game dice.

  • 1,192 views
  • 5 comments
  • 8 respects

Components and supplies

About this project

Ideation

This project was based on the idea that I had become bored of my normal standard game dice. So, to fix my boredom, I decided to use my Arduino LCD and standard push button (with a breakout board) and I had the Arduino read the state of the signal pin on the button board to high or low (high if button not depressed) (low if not). Depending on the state it would either stay on the main screen or show that the dice are rolling and then print out two random numbers from 1-6 (like a dice).

Code

The codeArduino
#include <LiquidCrystal.h>
long randNumber;
int Led = 13; //define LED port
int Shock = 2; //define shock port
int val;//define digital variable val
// initialize the library with the numbers of the interface pins
LiquidCrystal lcd(7, 8, 9, 10, 11, 12 );
byte customChar[] = {
  B00000,
  B00000,
  B11111,
  B11001,
  B10101,
  B10011,
  B11111,
  B00000
};
void  setup()
{
  
  lcd.begin(16, 2);
  lcd.createChar(0, customChar);
  lcd.home();
  pinMode(Led, OUTPUT); //define LED as a output port
  randomSeed(analogRead(0));
  pinMode(Shock, INPUT); //define shock sensor as a output port
  lcd.write(byte( 0));
  lcd.print("Digital dice");
  lcd.write(byte( 0));
  delay(1000);
}

void  loop()
{
  
  val = digitalRead(Shock); //read the value of the digital interface 3 assigned to val
  if (val == LOW) //when the shock sensor have signal do the following
  {
     lcd.clear();
     lcd.print("Rolling dice...");
     delay(4000);
     lcd.clear();
     lcd.setCursor(0, 0);
     randNumber = random(1,7);
     lcd.print("Dice 1 = ");
     lcd.print(randNumber);
     
     lcd.setCursor(0, 1);
     randNumber = random(1,7);
     lcd.print("Dice 2 = ");
     lcd.print(randNumber);
     
  }
 
 delay(150);
}

Schematics

The schematic
Dice game bb 8eujm9rety

Comments

Similar projects you might like

Simple Arduino Digital Clock Without RTC

Project in progress by Annlee Fores

  • 96,159 views
  • 23 comments
  • 80 respects

Digital Dice

Project showcase by SKYMDev

  • 1,355 views
  • 0 comments
  • 0 respects

Settlers Of Catan Dice

Project tutorial by joshi

  • 6,335 views
  • 13 comments
  • 29 respects

Simplest UNO Digital Clock Ever

Project tutorial by plouc68000

  • 4,014 views
  • 9 comments
  • 27 respects

Arduino Digital Clock Using 1Sheeld

Project tutorial by amrmostaafaa

  • 2,224 views
  • 0 comments
  • 5 respects

MicroView Digital Dice

Project tutorial by Giovanni Gentile

  • 795 views
  • 1 comment
  • 2 respects
Add projectSign up / Login