EasyManuals Logo

Arduino Pro Mini User Manual

Arduino Pro Mini
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #64 background imageLoading...
Page #64 background image
BinaryDice/Blink/Blink.ino
const unsigned int LED_PIN = 12;
const unsigned int PAUSE = 500;
void setup() {
pinMode(LED_PIN, OUTPUT);
}
void loop() {
digitalWrite(LED_PIN, HIGH);
delay(PAUSE);
digitalWrite(LED_PIN, LOW);
delay(PAUSE);
}
Weve built a strong foundation for our project, and in the next section well
build upon it.
First Version of a Binary Die
Youre 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, youd need
seven LEDs and some fairly complicated business logic. Well 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 on a breadboard. Controlling
three LEDs is similar and requires only more wires, LEDs, 1k resistors, and
pins. Figure 11, A first working version of our binary die, on page 46 shows
the first working version of a binary die.
The most important difference is the common ground. When you need ground
for a single LED, you can connect it to the LED directly. But we need ground
for three LEDs now, so well use the breadboards rows for the first time.
Connect the row marked with a hyphen (-) to the Arduinos ground pin, and
report erratum discuss
First Version of a Binary Die 45
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino Pro Mini and is the answer not in the manual?

Arduino Pro Mini Specifications

General IconGeneral
BrandArduino
ModelPro Mini
CategoryMotherboard
LanguageEnglish

Related product manuals