Introduction |
|
xxv | |
|
PART I Arduino Engineering Basics |
|
|
1 | (66) |
|
1 Getting Started and Understanding the Arduino Landscape |
|
|
3 | (20) |
|
Exploring the Arduino Ecosystem |
|
|
4 | (11) |
|
|
5 | (2) |
|
|
7 | (1) |
|
|
8 | (1) |
|
Input/Output: GPIO, ADCs, and Communication Busses |
|
|
9 | (1) |
|
|
9 | (2) |
|
|
11 | (4) |
|
Creating Your First Program |
|
|
15 | (6) |
|
Downloading and Installing the Arduino IDE |
|
|
16 | (1) |
|
Running the IDE and Connecting to the Arduino |
|
|
17 | (1) |
|
Breaking Down Your First Program |
|
|
18 | (3) |
|
|
21 | (2) |
|
2 Digital Inputs, Outputs, and Pulse-Width Modulation |
|
|
23 | (24) |
|
|
24 | (7) |
|
Wiring Up an LED and Using Breadboards |
|
|
24 | (1) |
|
|
24 | (1) |
|
|
25 | (4) |
|
Programming Digital Outputs |
|
|
29 | (1) |
|
|
30 | (1) |
|
Pulse-Width Modulation with analogWrite() |
|
|
31 | (4) |
|
|
35 | (7) |
|
Reading Digital Inputs with Pull-Down Resistors |
|
|
35 | (3) |
|
Working with "Bouncy" Buttons |
|
|
38 | (4) |
|
Building a Controllable RGB LED Nightlight |
|
|
42 | (4) |
|
|
46 | (1) |
|
3 Interfacing with Analog Sensors |
|
|
47 | (20) |
|
Understanding Analog and Digital Signals |
|
|
48 | (3) |
|
Comparing Analog and Digital Signals |
|
|
48 | (1) |
|
Converting an Analog Signal to Digital |
|
|
49 | (2) |
|
Reading Analog Sensors with the Arduino: analogRead() |
|
|
51 | (9) |
|
|
51 | (5) |
|
|
56 | (4) |
|
Using Variable Resistors to Make Your Own Analog Sensors |
|
|
60 | (6) |
|
Using Resistive Voltage Dividers |
|
|
61 | (3) |
|
Using Analog Inputs to Control Analog Outputs |
|
|
64 | (2) |
|
|
66 | (1) |
|
PART II Interfacing with Your Environment |
|
|
67 | (132) |
|
4 Using Transistors and Driving DC Motors |
|
|
69 | (30) |
|
|
70 | (16) |
|
Handling High-Current Inductive Loads |
|
|
71 | (1) |
|
Using Transistors as Switches |
|
|
72 | (1) |
|
|
73 | (1) |
|
Using a Secondary Power Source |
|
|
74 | (1) |
|
|
74 | (2) |
|
Controlling Motor Speed with PWM |
|
|
76 | (2) |
|
Using an H-Bridge to Control DC Motor Direction |
|
|
78 | (2) |
|
Building an H-Bridge Circuit |
|
|
80 | (2) |
|
Operating an H-Bridge Circuit |
|
|
82 | (4) |
|
|
86 | (11) |
|
|
87 | (1) |
|
Selecting a Motor and Gearbox |
|
|
87 | (1) |
|
|
87 | (2) |
|
|
89 | (3) |
|
Writing the Robot Software |
|
|
92 | (4) |
|
|
96 | (1) |
|
|
97 | (2) |
|
5 Driving Stepper and Servo Motors |
|
|
99 | (26) |
|
|
100 | (5) |
|
Understanding the Difference between Continuous Rotation and Standard Servos |
|
|
100 | (1) |
|
Understanding Servo Control |
|
|
101 | (3) |
|
|
104 | (1) |
|
Building a Sweeping Distance Sensor |
|
|
105 | (4) |
|
Understanding and Driving Stepper Motors |
|
|
109 | (8) |
|
How Bipolar Stepper Motors Work |
|
|
111 | (2) |
|
|
113 | (4) |
|
Building a "One-Minute Chronograph" |
|
|
117 | (7) |
|
Wiring and Building the Chronograph |
|
|
117 | (2) |
|
Programming the Chronograph |
|
|
119 | (5) |
|
|
124 | (1) |
|
6 Making Sounds and Music |
|
|
125 | (16) |
|
Understanding How Speakers Work |
|
|
126 | (3) |
|
|
126 | (2) |
|
How a Speaker Produces Sound |
|
|
128 | (1) |
|
Using tone() to Make Sounds |
|
|
129 | (7) |
|
Including a Definition File |
|
|
129 | (1) |
|
|
130 | (3) |
|
|
133 | (1) |
|
|
133 | (1) |
|
Making Note and Duration Arrays |
|
|
134 | (1) |
|
|
134 | (2) |
|
Understanding the Limitations of the tone() Function |
|
|
136 | (1) |
|
|
136 | (3) |
|
|
139 | (2) |
|
7 USB Serial Communication |
|
|
141 | (30) |
|
Understanding the Arduino's Serial Communication Capabilities |
|
|
142 | (6) |
|
Arduino Boards with an Internal or External FTDI or Silicon Labs USB-to-Serial Converter |
|
|
143 | (3) |
|
Arduino Boards with a Secondary USB-Capable ATmega MCU Emulating a Serial Converter |
|
|
146 | (1) |
|
Arduino Boards with a Single USB-Capable MCU |
|
|
147 | (1) |
|
Arduino Boards with USB-Host Capabilities |
|
|
147 | (1) |
|
|
148 | (4) |
|
|
148 | (2) |
|
|
150 | (2) |
|
Changing Data Type Representations |
|
|
152 | (1) |
|
|
152 | (9) |
|
Configuring the Arduino IDE's Serial Monitor to Send Command Strings |
|
|
152 | (1) |
|
Reading Incoming Data from a Computer or Other Serial Device |
|
|
153 | (1) |
|
Telling the Arduino to Echo Incoming Data |
|
|
153 | (1) |
|
Understanding the Differences between Chars and Ints |
|
|
154 | (2) |
|
Sending Single Characters to Control an LED |
|
|
156 | (2) |
|
Sending Lists of Values to Control an RGB LED |
|
|
158 | (3) |
|
|
161 | (8) |
|
|
162 | (1) |
|
Controlling a Processing Sketch from Your Arduino |
|
|
163 | (3) |
|
Sending Data from Processing to Your Arduino |
|
|
166 | (3) |
|
|
169 | (2) |
|
|
171 | (12) |
|
|
173 | (5) |
|
Typing Data into the Computer |
|
|
173 | (4) |
|
Commanding Your Computer to Do Your Bidding |
|
|
177 | (1) |
|
|
178 | (4) |
|
|
182 | (1) |
|
|
183 | (16) |
|
Understanding Shift Registers |
|
|
184 | (8) |
|
Sending Parallel and Serial Data |
|
|
185 | (1) |
|
Working with the 74HC595 Shift Register |
|
|
186 | (1) |
|
Understanding the Shift Register pin Functions |
|
|
186 | (1) |
|
Understanding How the Shift Register Works |
|
|
187 | (2) |
|
Shifting Serial Data from the Arduino |
|
|
189 | (3) |
|
Converting Between Binary and Decimal Formats |
|
|
192 | (1) |
|
Controlling Light Animations with a Shift Register |
|
|
192 | (5) |
|
|
192 | (2) |
|
Responding to Inputs with an LED Bar Graph |
|
|
194 | (3) |
|
|
197 | (2) |
|
PART III Communication Interfaces |
|
|
199 | (74) |
|
|
201 | (22) |
|
|
202 | (1) |
|
|
203 | (5) |
|
Communication Scheme and ID Numbers |
|
|
203 | (3) |
|
Hardware Requirements and Pull-Up Resistors |
|
|
206 | (2) |
|
Communicating with an PC Temperature Probe |
|
|
208 | (6) |
|
|
208 | (2) |
|
Referencing the Datasheet |
|
|
210 | (2) |
|
|
212 | (2) |
|
Combining Shift Registers, Serial Communication, and PC Communications |
|
|
214 | (7) |
|
Building the Hardware for a Temperature Monitoring System |
|
|
214 | (1) |
|
Modifying the Embedded Program |
|
|
215 | (3) |
|
Writing the Processing Sketch |
|
|
218 | (3) |
|
|
221 | (2) |
|
11 The SPI Bus and Third-Party Libraries |
|
|
223 | (24) |
|
|
224 | (1) |
|
SPI Hardware and Communication Design |
|
|
225 | (2) |
|
|
225 | (2) |
|
|
227 | (1) |
|
Comparing SPI to PC and UART |
|
|
227 | (1) |
|
Communicating with an SPI Accelerometer |
|
|
228 | (13) |
|
What Is an Accelerometer? |
|
|
229 | (2) |
|
Gathering Information from the Datasheet |
|
|
231 | (2) |
|
|
233 | (2) |
|
|
235 | (1) |
|
Installing the Adafruit Sensor Libraries |
|
|
236 | (1) |
|
|
237 | (4) |
|
Creating an Audiovisual Instrument Using a 3-Axis Accelerometer |
|
|
241 | (5) |
|
|
242 | (1) |
|
|
242 | (4) |
|
|
246 | (1) |
|
12 Interfacing with Liquid Crystal Displays |
|
|
247 | (26) |
|
|
248 | (3) |
|
Using the LiquidCrystal Library to Write to the LCD |
|
|
251 | (7) |
|
Adding Text to the Display |
|
|
252 | (2) |
|
Creating Special Characters and Animations |
|
|
254 | (4) |
|
Building a Personal Thermostat |
|
|
258 | (13) |
|
|
258 | (3) |
|
Displaying Data on the LCD |
|
|
261 | (3) |
|
Adjusting the Set Point with a Button |
|
|
264 | (1) |
|
Adding an Audible Warning and a Fan |
|
|
265 | (1) |
|
Bringing It All Together: The Complete Program |
|
|
266 | (4) |
|
Taking This Project to the Next Level |
|
|
270 | (1) |
|
|
271 | (2) |
|
PART IV Digging Deeper and Combining Functions |
|
|
273 | (64) |
|
13 Interrupts and Other Special Functions |
|
|
275 | (20) |
|
Using Hardware Interrupts |
|
|
276 | (12) |
|
Knowing the Tradeoffs Between Polling and Interrupting |
|
|
277 | (1) |
|
Ease of Implementation (Software) |
|
|
277 | (1) |
|
Ease of Implementation (Hardware) |
|
|
277 | (1) |
|
|
278 | (1) |
|
|
278 | (1) |
|
Understanding the Arduino Hardware Interrupt Capabilities |
|
|
278 | (1) |
|
Building and Testing a Hardware-Debounced Button Interrupt Circuit |
|
|
279 | (1) |
|
Creating a Hardware-Debouncing Circuit |
|
|
280 | (4) |
|
Assembling the Complete Test Circuit |
|
|
284 | (1) |
|
|
285 | (3) |
|
|
288 | (2) |
|
Understanding Timer Interrupts |
|
|
288 | (1) |
|
|
289 | (1) |
|
Executing Two Tasks Simultaneously(ish) |
|
|
289 | (1) |
|
Building an Interrupt-Driven Sound Machine |
|
|
290 | (4) |
|
|
291 | (1) |
|
|
291 | (3) |
|
|
294 | (1) |
|
14 Data Logging with SD Cards |
|
|
295 | (42) |
|
Getting Ready for Data Logging |
|
|
296 | (8) |
|
Formatting Data with CSV Files |
|
|
297 | (1) |
|
Preparing an SD Card for Data Logging |
|
|
297 | (1) |
|
Formatting Your SD Card Using a Windows PC |
|
|
298 | (2) |
|
Formatting Your SD Card Using Mac OS |
|
|
300 | (2) |
|
Formatting Your SD Card Using Linux |
|
|
302 | (2) |
|
Interfacing the Arduino with an SD Card |
|
|
304 | (13) |
|
|
304 | (3) |
|
|
307 | (1) |
|
|
307 | (5) |
|
|
312 | (5) |
|
|
317 | (10) |
|
Understanding Real-Time Clocks |
|
|
317 | (1) |
|
Communicating with a Real-Time Clock |
|
|
317 | (1) |
|
Using the RTC Arduino Third-Party Library |
|
|
318 | (1) |
|
|
319 | (1) |
|
Installing the RTC and SD Card Modules |
|
|
319 | (1) |
|
|
320 | (7) |
|
Building an Entrance Logger |
|
|
327 | (8) |
|
|
328 | (1) |
|
|
329 | (5) |
|
|
334 | (1) |
|
|
335 | (2) |
|
|
337 | (114) |
|
15 Wireless RF Communications |
|
|
339 | (24) |
|
The Electromagnetic Spectrum |
|
|
340 | (6) |
|
|
342 | (1) |
|
How Your RF Link Will Send and Receive Data |
|
|
343 | (3) |
|
Receiving Key Presses with the RF Link |
|
|
346 | (5) |
|
|
346 | (1) |
|
Programming Your Receiver |
|
|
347 | (4) |
|
Making a Wireless Doorbell |
|
|
351 | (3) |
|
|
351 | (1) |
|
|
351 | (3) |
|
The Start of Your Smart Home---Controlling a Lamp |
|
|
354 | (7) |
|
|
356 | (1) |
|
|
356 | (2) |
|
Programming the Relay Control |
|
|
358 | (2) |
|
Hooking up Your Lamp and Relay to the Arduino |
|
|
360 | (1) |
|
|
361 | (2) |
|
16 Bluetooth Connectivity |
|
|
363 | (36) |
|
|
364 | (2) |
|
Bluetooth Standards and Versions |
|
|
364 | (1) |
|
Bluetooth Profiles and BTLE GATT Services |
|
|
365 | (1) |
|
Communication between Your Arduino and Your Phone |
|
|
366 | (23) |
|
Reading a Sensor over BTLE |
|
|
366 | (1) |
|
Adding Support for Third-Party Boards to the Arduino IDE |
|
|
367 | (2) |
|
Installing the BTLE Module Library |
|
|
369 | (1) |
|
Programming the Feather Board |
|
|
369 | (8) |
|
Connecting Your Smartphone to Your BTLE Transmitter |
|
|
377 | (2) |
|
Sending Commands from Your Phone over BTLE |
|
|
379 | (1) |
|
|
380 | (4) |
|
Commanding Your BTLE Device with Natural Language |
|
|
384 | (5) |
|
Controlling an AC Lamp with Bluetooth |
|
|
389 | (8) |
|
How Your Phone "Pairs" to BTLE Devices |
|
|
389 | (1) |
|
Writing the Proximity Control Software |
|
|
390 | (4) |
|
|
394 | (1) |
|
|
394 | (1) |
|
|
395 | (1) |
|
Make Your Lamp React to Your Presence |
|
|
396 | (1) |
|
|
397 | (2) |
|
|
399 | (52) |
|
The Web, the Arduino, and You |
|
|
400 | (4) |
|
|
401 | (1) |
|
The Internet vs. the World Wide Web vs. the Cloud |
|
|
401 | (1) |
|
|
401 | (1) |
|
Network Address Translation |
|
|
402 | (1) |
|
|
402 | (1) |
|
|
402 | (1) |
|
|
402 | (1) |
|
|
403 | (1) |
|
|
403 | (1) |
|
|
403 | (1) |
|
|
403 | (1) |
|
Your Wi-Fi-Enabled Arduino |
|
|
404 | (1) |
|
Controlling Your Arduino from the Web |
|
|
404 | (23) |
|
Setting Up the I/O Control Hardware |
|
|
404 | (2) |
|
Preparing the Arduino IDE for Use with the Feather Board |
|
|
406 | (1) |
|
Ensuring the Wi-Fi Library Is Matched to the Wi-Fi Module's Firmware |
|
|
407 | (1) |
|
Checking the WINC1500's Firmware Version |
|
|
408 | (1) |
|
Updating the WINC1500's Firmware |
|
|
408 | (1) |
|
Writing an Arduino Server Sketch |
|
|
408 | (1) |
|
Connecting to the Network and Retrieving an IP Address via DHCP |
|
|
409 | (3) |
|
Writing the Code for a Bare-Minimum Web Server |
|
|
412 | (11) |
|
Controlling Your Arduino from Inside and Outside Your Local Network |
|
|
423 | (1) |
|
Controlling Your Arduino over the Local Network |
|
|
423 | (2) |
|
Using Port Forwarding to Control Your Arduino from Anywhere |
|
|
425 | (2) |
|
Interfacing with Web APIs |
|
|
427 | (22) |
|
|
428 | (1) |
|
Creating an Account with the API Service Provider |
|
|
429 | (1) |
|
Understanding How APIs Are Structured |
|
|
430 | (1) |
|
JSON-Formatted Data and Your Arduino |
|
|
430 | (1) |
|
Fetching and Parsing Weather Data |
|
|
431 | (2) |
|
Getting the Local Temperature from the Web on Your Arduino |
|
|
433 | (7) |
|
Completing the Live Temperature Display |
|
|
440 | (1) |
|
Wiring up the LED Readout Display |
|
|
440 | (3) |
|
Driving the Display with Temperature Data |
|
|
443 | (6) |
|
|
449 | (2) |
Appendix A: Deciphering Datasheets and Schematics |
|
451 | (10) |
Index |
|
461 | |