EasyManuals Logo

Arduino NG User Manual

Arduino NG
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 #75 background imageLoading...
Page #75 background image
Figure 13Our binary die now has a guess button.
BinaryDice/DiceGame/DiceGame.ino
#include <Bounce2.h>
Line 1
const unsigned int LED_BIT0 = 12;
-
const unsigned int LED_BIT1 = 11;
-
const unsigned int LED_BIT2 = 10;
-
const unsigned int GUESS_BUTTON_PIN = 5;
5
const unsigned int START_BUTTON_PIN = 7;
-
const unsigned int BAUD_RATE = 9600;
-
const unsigned int DEBOUNCE_DELAY = 20;
-
-
int guess = 0;
10
Bounce start_button;
-
Bounce guess_button;
-
-
void setup() {
-
pinMode(LED_BIT0, OUTPUT);
15
pinMode(LED_BIT1, OUTPUT);
-
pinMode(LED_BIT2, OUTPUT);
-
pinMode(START_BUTTON_PIN, INPUT);
-
pinMode(GUESS_BUTTON_PIN, INPUT);
-
start_button.attach(START_BUTTON_PIN);
20
start_button.interval(DEBOUNCE_DELAY);
-
guess_button.attach(GUESS_BUTTON_PIN);
-
guess_button.interval(DEBOUNCE_DELAY);
-
randomSeed(analogRead(A0));
-
Serial.begin(BAUD_RATE);
25
}
-
-
Chapter 3. Building Binary Dice 56
report erratum discuss
www.it-ebooks.info

Table of Contents

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino NG Specifications

General IconGeneral
BrandArduino
ModelNG
CategoryMotherboard
LanguageEnglish

Related product manuals