top of page
  • Writer's pictureAlan Seder

EDTEC 568 - Arduino Challenge - The Fourth Week

Updated: Dec 8, 2020

Welcome to the fourth week of EDTEC 568 - Makerspaces Build Challenge. This week's challenge is to build a simulated random die roll simulating the outcome of the roll using seven LED's arranged to represent the dots on a die face. When a random number is generated, the appropriate LED dots should light up in the configuration appropriate for the face of the die roll in question. To initiate the random die roll a button switch should be pressed to set the roll in motion and lead to the LED dots display of the outcome. To begin, we will take a look at the RGB DIE project code I generated in Sketch on the Arduino IDE shown below. Each of the seven LED's is activated by a digital pin assignment using digital pins 3 through 9. The button switch input is assigned to digital pin 2. The random die roll is set in motion by reading the digital pin 2 input to check if the button switch is pushed. If the button switch (pull-down resistor circuit) is closed, a random number from 1 through 6 inclusive is generated. Based upon the random number generated a user defined function is called to activate the correct combination of LED's through the digital pin outputs to simulate the face of the die. This configuration is held for two seconds (note pushing the button early has no effect), then the LED's are switch off and the program cycles idly until the button switch is closed again. Note the code below also contains an extension to animate the die roll using a user defined function, which I will discuss later in this post.

LED DIE Code

Next, below is an image of my Arduino Uno and the breadboard with LED DIE circuit I built. Note that a bit of circuit layout creativity was required to make the LED's configuration function, if not somewhat aesthetically pleasing, without unnecessary amounts of clutter on the breadboard. I opted to have each LED on its own circuit with its own digital pin assignment. There are other possibilities, but this is the most straight forward for both circuit design and coding. I also opted to run all the 220 ohm resistors on the ground side of all the LED's and have the digital pin outputs directly to the positive side of the LED's to create a flow across the breadboard. I placed the pull-down resistor button switch away from the LED's to avoid disturbing the LED's when pressing the button.


The circuit diagram for the LED DIE is below. Probably the most challenging question I had to work through in the circuit design was whether to set up the button switch with a pull-up or a pull-down resistor circuit. The choice figured most prominently in how I wanted to use the button switch in the sketch code to activate the random roll; ultimately I decided a positive circuit closure would be the best choice to avoid poor contacts triggering a spurious random roll.


The following video shows the LED DIE project in action and describes the workings of the circuit and features of the Sketch code uploaded from the Arduino IDE.


Initially, I thought about this project as a way to be clever about minimizing LED outputs; and I actually worked out a way to use four outputs to special groups of LED's. I reconsidered and went with a circuit layout challenge requiring all seven LED outputs. Laying this out on a breadboard in a die face configuration in a manner that flowed without excessive clutter seemed interesting; it was.


Upon reflection, I realized I have always been a "function over form" type of person. I like things to work as they are supposed to function. I often have little patience for making something aesthetically pleasing. What I truly loath is doing something for show that has no function or misleads about its function; sadly, this appears to be the preferred mode for administrator driven initiatives, but I digress. When I managed to make the die simulation function, I was happy but also underwhelmed. In a moment of personal growth, I realized there is a fourth course to follow - adding some showy aspects to enhance the functionality of something. Thus, my extension this week is my personal growth badge.


Now, a bit of discussion of my extension this week. While getting the project to do the basic random roll and die face display was satisfying, the rolling process itself felt a bit underwhelming. So, I wrote a user defined function called razzleDazzle() that runs the LED's through all of the die face combinations before displaying the random roll generated. The effect feels to me like a bit of animation of the rolling process that spices up the simulation and makes me smile.


Finally, below is a frequency distribution for 200 rolls of the LED Die.


35 views0 comments

Kommentare


Post: Blog2_Post
bottom of page