First Version of a Binary Die
You’re certainly familiar with a regular die displaying results in a range from one to six. To emulate such a die exactly with an electronic device, you’d need seven LEDs and some fairly complicated business logic. We’ll take a shortcut and display the result of a die roll in binary.
For a binary die, we need only three LEDs to represent the current result. We turn the result into a binary number, and for every bit that is set, we light up a corresponding LED. The following diagram shows how the die results are mapped to LEDs. (A black triangle stands for a shining LED.)
We already know how to control a single LED ...
Get Arduino: A Quick-Start Guide, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.