Note details

Raspberry Pi Pico Project: Nerdy Digital Dice (D4 to D20)

BY 6vjhr
July 7, 2025
Public
Private
2695 views

Digital Dice Project Overview

Introduction

  • Ideal project for beginners to learn about microcontrollers, circuits, and programming.
  • The project involves creating a digital dice set using a microcontroller, a display, and a button.

Requirements

  • Materials Needed:
    • Microcontroller (e.g., Raspberry Pi Pico, Raspberry Pi Pico 2, Arduino)
    • Small OLED display (e.g., 0.91 inch)
    • Two push buttons
    • Breadboard
    • Connecting wires
    • A PC to program the microcontroller using Thonny IDE and MicroPython

Project Components and Setup

  • Microcontroller:
    • Raspberry Pi Pico utilized with MicroPython.
  • Display:
    • Connect the display using I2C protocol.
    • SC pin: Connect to GPIO 15.
    • SDA pin: Connect to GPIO 14.
    • Power pins: Connect to 3.3V and ground.
  • Buttons:
    • First button to roll the dice.
    • Second button to select dice type (e.g., 4-sided, 6-sided, 8-sided, 12-sided, 20-sided).
    • Connect one side of the button to ground and the other side to respective GPIO pins.

Coding Aspects

  • MicroPython Code:
    • Uses the I2C protocol for controlling the display.
    • Implement functions to:
      • Initialize the display driver.
      • Read button inputs with debouncing.
      • Update the display with the current dice number.
  • Button Handling:
    • Handle button press events to modify dice type and initiate rolls.
    • Address button bouncing by implementing debouncing logic.

Display Logic

  • Custom Font Display:
    • Define custom pixel arrays for numbers and dice faces.
    • Use functions to print these arrays on the display.

Conclusion

  • A versatile beginner project that can be extended to use buttons and displays for various applications.
  • Encouragement to provide feedback and request additional projects.
  • Project code is available on GitHub for reference and use.