EasyManuals Logo

Arduino uno User Manual

Arduino uno
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 #127 background imageLoading...
Page #127 background image
void loop() {
Serial.print(get_x());
Serial.print(" ");
Serial.print(get_y());
Serial.print(" ");
Serial.print(get_z());
Serial.print(" ");
if (button.update()) {
button_pressed = button.read() == HIGH;
}
Serial.println(button_pressed == HIGH ? "1" : "0");
delay(10);
}
As in Building a Dice Game, on page 55, we use the
Bounce
class to debounce
the button. The rest of the code is pretty much standard, and the only thing
worth mentioning is that we use a 38,400 baud rate to transfer the controller
data sufficiently fast.
Compile and upload the code, open the serial terminal, and play around with
the controller. Move it, press the button sometimes, and it should output
something like the following:
324 365 396 0
325 364 397 0
325 364 397 1
325 364 397 0
325 365 397 0
325 365 397 1
326 364 397 0
A homemade game controller is nice, and you can use it for many projects.
For example, you could use it to control devices such as a robot, a marble
maze, or something similar. Its original purpose is to control games, so well
build one in the next chapter.
More Projects
If you keep your eyes open, youll quickly find many more applications for
accelerometers than you might imagine. Heres a small collection of both
commercial and free products:
report erratum discuss
More Projects 109
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

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

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals