• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar
  • Skip to footer

The Coding Couple

Pair programming is a lifetime commitment.

  • Home
  • Categories
    • Arduino
    • JavaScript
    • Python
    • Raspberry Pi
  • About Us
    • Privacy Policy
  • Contact

Creation Crate Month 4: An Arduino powered LED dice game

August 19, 2016 by Ashley

Tinkering with microcontrollers has been on my “to try” list for quite some time.  I recently stumbled upon Creation Crate.  Creation Crate is a monthly tech education subscription box.  Each month you receive a Arduino UNO R3 and parts to complete a project. The instruction book includes the source code for the project.  The source code is licensed under the GNU General Public License.  Each month the projects increase in difficulty.  I thought Creation Crate would be a wonderful way to get my feet with wet with Arduino and programming electronics.

I was on the fence about signing up for the subscription box because I was not sure what to expect.  I intend to write a blog post for each Creation Crate I receive in case there is a reader out there on the fence like I was.

The Project

The project for Month 4 is a LED dice game.  The Arduino project simulates the roll of a 6-sided dice.

Creation Crate Month 4: An Arduino powered LED Dice Game

Creation Crate Month 4: An Arduino powered LED Dice Game

What’s in the box?

Inside of Month four’s box we have:

  • Arduino UNO R3
  • Breadboard
  • USB Cable
  • Yellow LEDs
  • Resistors
  • Jumper wires
  • Push button with cap
Creation Crate Month 4's contents

Creation Crate Month 4’s contents

Building the Hardware

Assembly for Month 4’s project was pretty easy.

Adding the U-shaped jumper wires to the breadboard

Adding the U-shaped jumper wires to the breadboard

 

Adding the LEDs

Adding the LEDs

 

Adding a push button

Adding resistors and a push button

 

The little guy is really interested in this month's project

The little guy is really interested in this month’s project

 

Hardware construction complete

Hardware construction complete

Programming

Last month, steps were omitted for assembling the hardware.  This month, the challenge is on the software side.  Sections of code are omitted from the instruction book.  It is not a difficult exercise, but it will encourage you to pay more attention to which pins the inputs and outputs are plugged into.

// License: GNU General Public License
// Creation Crate Month 4 - LED Dice Game
#define button 3
#define ledSet1 4
#define ledSet2 5
#define ledSet3 6
#define ledSet4 7
// tracks if the button is on or off
int buttonState;
// stores random number between 1 and 6
int roll;
// 2 seconds
int time = 2000;
void setup() {
// put your setup code here, to run once:
pinMode(ledSet1, OUTPUT);
pinMode(ledSet2, OUTPUT);
pinMode(ledSet3, OUTPUT);
pinMode(ledSet4, OUTPUT);
pinMode(button, INPUT);
randomSeed(analogRead(0));
Serial.begin(9600);
}
void loop() {
// put your main code here, to run repeatedly:
buttonState = digitalRead(button);
if(buttonState == HIGH) {
roll = random(1, 7);
if(roll == 1) {
digitalWrite(ledSet3, HIGH);
}
else if(roll == 2) {
digitalWrite(ledSet1, HIGH);
}
else if(roll == 3) {
digitalWrite(ledSet1, HIGH);
digitalWrite(ledSet3, HIGH);
}
else if(roll == 4) {
digitalWrite(ledSet2, HIGH);
digitalWrite(ledSet4, HIGH);
}
else if(roll == 5) {
digitalWrite(ledSet2, HIGH);
digitalWrite(ledSet3, HIGH);
digitalWrite(ledSet4, HIGH);
}
else if(roll == 6) {
digitalWrite(ledSet1, HIGH);
digitalWrite(ledSet2, HIGH);
digitalWrite(ledSet4, HIGH);
}
}
Serial.print("You rolled a ");
Serial.println(roll);
delay(time);
// turn off all the LEDs
digitalWrite(ledSet1, LOW);
digitalWrite(ledSet2, LOW);
digitalWrite(ledSet3, LOW);
digitalWrite(ledSet4, LOW);
}
view raw led_dice_game.ino hosted with ❤ by GitHub

Final Thoughts

The LED dice game is a really simple Arduino project. I hope next month we’ll see a nice increase in difficulty.

Related Posts

  • Creation Crate Month 2: An Arduino Powered Memory GameCreation Crate Month 2: An Arduino Powered Memory Game
  • Creation Crate Month 1: An Arduino powered Mood LampCreation Crate Month 1: An Arduino powered Mood Lamp
  • Creation Crate Month 3: An Arduino Powered Distance DetectorCreation Crate Month 3: An Arduino Powered Distance Detector
  • AdaBox 005: Break for Pi | Adafruit Subscription BoxAdaBox 005: Break for Pi | Adafruit Subscription Box
  • JavaScript’s Null Coalescing Operator | Today I LearnedJavaScript’s Null Coalescing Operator | Today I Learned
  • Pixel Color Count legendCounting Pixels by Color in Python with Pillow (a PIL fork)

Filed Under: Arduino Tagged With: arduino, creation crate, dice, game, led, month 4, subscription box

Previous Post: « Creation Crate Month 3: An Arduino Powered Distance Detector
Next Post: Adafruit Joy Bonnet for the Raspberry Pi »

Reader Interactions

Comments

  1. Dave Beck says

    August 20, 2016 at 5:56 am

    Cool project! Great to see the little guys helping out.

Primary Sidebar

Social Media

  • GitHub
  • Instagram
  • Twitter
  • YouTube

Recent Posts

  • Pokémon Color Picker | A web app built with HTML/CSS + JavaScript
  • Pokéball Single DIV CSS Drawing | Tutorial
  • Error: [🍍]: “getActivePinia()” was called but there was no active Pinia
  • Trijam #261 Game Jam Diary: One Wrong Move
  • Using WSL on Corporate VPN

Recent Comments

  • Lizzy on Creation Crate Month 2: An Arduino Powered Memory Game
  • Ashley Grenon on Creation Crate Month 2: An Arduino Powered Memory Game
  • Lizzy on Creation Crate Month 2: An Arduino Powered Memory Game
  • kelly on Creation Crate Month 2: An Arduino Powered Memory Game
  • Ashley on Creation Crate Month 3: An Arduino Powered Distance Detector

Follow us on Instagram!

This error message is only visible to WordPress admins

Error: No feed found.

Please go to the Instagram Feed settings page to create a feed.

Categories

  • Arduino
  • Conferences
  • Debugging
  • Game Jams
  • HTML and CSS
  • JavaScript
  • Programming Languages
  • Python
  • Raspberry Pi
  • Today I Learned

Archives

  • May 2024
  • April 2024
  • March 2024
  • May 2022
  • December 2021
  • May 2021
  • March 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • June 2019
  • April 2019
  • September 2017
  • April 2017
  • August 2016
  • July 2016
  • June 2016
  • May 2016
  • April 2016
  • March 2016
  • April 2015
  • January 2015

Tags

adafruit arduino brackets c# code smell codestock coding standards conventions creation crate debugging developer devspace electronics es6 es2015 game development game jam gotcha hackathon hoisting html html5 javascript led naming conventions nintendo phaser pluralsight pokemon programmer python raspberry pi retro retropie scope self improvement single div single div drawing subscription box TIL today I learned troubleshooting vue vuejs windbg

Footer

About Us

The Coding Couple: Ashley and Michael

We are the Coding Couple.  Two people who met in college and decided they wanted to pair program for the rest of their ...

Read More »

Most Recent Posts

Pokémon Color Picker | A web app built with HTML/CSS + JavaScript

Pokéball Single DIV CSS Drawing | Tutorial

Error: [🍍]: “getActivePinia()” was called but there was no active Pinia

Trijam #261 Game Jam Diary: One Wrong Move

Social Media

  • GitHub
  • Instagram
  • Twitter
  • YouTube

Copyright Notice

© The Coding Couple, 2015 – 20235. Excerpts and links may be used, provided that full and clear credit is given to The Coding Couple with appropriate and specific direction to the original content.

Copyright © 2026 · Foodie Pro Theme by Shay Bocks · Built on the Genesis Framework · Powered by WordPress