Imagine this scenario: you're stuck at home like millions of other Americans in quarantine. You and the family decide to play a friendly game of Monopoly, the epitome of capitalist society. You bring out the Monopoly board from the closet; you haven't seen the box since your childhood, oh the memories. You open the box to realize, "oh no! we're missing a die!" What do you do? There aren't any spare die at your house, and you certainly can't go out to buy a die, that's a nonessential item!! So you pull out your laptop, Launchpad, and Sidekick to write a program that will roll a fair die for you! How ingenious! Your ELEC 220 knowledge is proving useful. The wonderful people at X.we11am have decided to make that program for you.
Our program will roll a random die and light up the 7-segment display with a color-coded number so that you get the best board game experience you can have during these troubling times!
Let's take you through.
Step 1: Developing the seven-segment display
Our first step was to develop a visual interface for our die. Luckily, our 7 segment display from our toolkit has the exact capabilities we were looking for. A more comprehensive tutorial on the code and circuitry can be found here.
Step 2: A die, of course, doesn't just cycle through numbers, so to emulate reality, we had to generate a random number between 1 to 6 using the random() function and display the number on the 7-segment display.
Step 3: Once we got a randomized number, we added a shuffle effect to replicate the experience of rolling a die as closely as possible.
Step 4: We hooked up the switch so that it triggers the randomized number generator. This makes it easy for board game players to “roll a die” by hitting a switch instead of having to run the code continuously. It’s also MUCH more satisfying as the tactile feel of the switch almost always feels better than running code on your computer!
Step 5: We were nearing completion when we got word from our clients of a brand new technology hitting the market! We needed to figure out how to implement the tilt switch. Through some testing, we determined the functionality of the new component. The team decided that when the board is tilted one way, the die is 'rolling' as if you were shaking it in your hand, and when the board is tilted the other way, the die is cast.
Step 6: When the board is tilted, random numbers and their respective colors are displayed. When the board returns to its original position, a singular number and color are displayed.
And with that, our project is complete! Not only do you have a fully functioning die, but it also comes with a visual feedback loop to make the simple act of rolling a die a fun experience for the whole family! Now get back to your game, it's been your turn for a while now...
Comments
Please log in or sign up to comment.