6.4 Digital Dice¶
This project builds upon the 2.5 Number Display project by adding a button to control the digit displayed on the seven-segment display.
In this project, a random number is generated and displayed on the seven-segment display to simulate a dice roll. When the button is pressed, a stable number (randomly selected from 1 to 6) is displayed on the seven-segment display. Pressing the button again will initiate the simulation of a dice roll, generating random numbers as before. This cycle continues each time the button is pressed.
Required Components
In this project, we need the following components.
It’s definitely convenient to buy a whole kit, here’s the link:
Name |
ITEMS IN THIS KIT |
LINK |
---|---|---|
ESP32 Starter Kit |
320+ |
You can also buy them separately from the links below.
COMPONENT INTRODUCTION |
PURCHASE LINK |
---|---|
- |
|
Schematic
This project builds upon the 2.5 7 Segment Display project by adding a button to control the digit displayed on the seven-segment display.
The button is directly connected to IO13 without an external pull-up or pull-down resistor because IO13 has an internal pull-up resistor of 47K, eliminating the need for an additional external resistor.
Wiring
Code
Note
Open the
6.4_digital_dice.ino
file under the path ofesp32-starter-kit-main\c\codes\6.4_digital_dice
.After selecting the board (ESP32 Dev Module) and the appropriate port, click the Upload button.
This project is based on 2.5 7 Segment Display with a button to start/pause the scrolling display on the 7-segment Display.
When the button is pressed, the 7-segment display scrolls through the numbers 1-6, and when the button is released, it displays a random number.