Industrial manufacturing
Industrial Internet of Things | Industrial materials | Equipment Maintenance and Repair | Industrial programming |
home  MfgRobots >> Industrial manufacturing >  >> Manufacturing Technology >> Manufacturing process

Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator

Components and supplies

Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
Breadboard (generic)
×1
Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
Jumper wires (generic)
×1
Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
Adafruit Standard LCD - 16x2 White on Blue
×1
Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
USB-A to B Cable
×1
Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
Arduino UNO
×1
Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
Rotary potentiometer (generic)
×1
Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator
SparkFun Pushbutton switch 12mm
×1

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 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

Arduino Digital Dice Project: Build Your Own LCD-based Random Number Generator

Manufacturing process

  1. TinyML Language Detector with Edge Impulse on Arduino Nano 33 BLE Sense
  2. Build a Real-Time Gyroscope Game with Arduino Nano & MPU-6050 Sensor
  3. Find Me: Smart Item Locator with Arduino and Bluetooth
  4. NeoPixel Matrix Pong on Arduino Nano: Build a Neon Pong Game
  5. Arduino-Powered Security System: Smart Motion Detection & Alert
  6. Build a Classic Arduino LCD Arcade Game with Buzzer and Joystick
  7. Arduino Tennis Game – Build a Virtual Racquet Experience with NeoPixel, Sensors, and Bluetooth
  8. Build a Smart Weather Station with Arduino UNO and AWS Integration
  9. Arduino Marble Maze Labyrinth – Build an Exciting Cardboard Board Game
  10. Build an Interactive LCD Game with Arduino UNO