INDEX

Please note that index links point to page beginnings from the print edition. Locations are approximate in e-readers, and you may need to page down one or more times after clicking a link to get to the indexed material.

Page numbers in italics refer to figures.

1-Wire bus standard, 169

family codes, 171

hardware, 169–170

initializing 1-Wire, 171

OneWire library, 170–173

protocol, 170

scanning the bus, 171–173

A

Adafruit Circuit Playground, 61–64

ADCs, 99, 107, 240

amplitude, 239

analog inputs, 9, 28–30

speeding up, 98–100

analog outputs, 30–32

analog-to-digital converters. See ADCs

and (&), 146

API, 271–272

defining, 274–275

application programmer interface. See API

Arduino

history of development, 39–40

overview, 1–4

Arduino Due, 12–13

digital signal processing (DSP), 247–249

as a USB host, 207–210

USB ports, 204

Arduino Ethernet, 212–213

Arduino Leonardo, 10–11

hardware interrupts, 74

power light, 8

Arduino m0, 11

Arduino Mega 2560, 12

hardware interrupts, 74

Arduino Mega ADK, 12

Arduino Pro Mini, 13

Arduino programming, 259–260

state diagrams, 265–266

Arduino String Object library, 130–131

Arduino Uno, 10–11

analog outputs, 30, 31

anatomy of, 7, 8, 40

connecting to an ATtiny for programming, 68–70

digital signal processing (DSP), 245–247

hardware interrupts, 74

vs. Mac laptop, 85–86

power light, 8

Arduino.h, 44–48

ArduinoISP sketch, 57, 69

ArduinoJson library, 224–226

Arduino-to-Arduino communication, 161–164, 196–198

arrays, 26–27

ASCII, 143

AT91SAM3X8E microprocessors, 43–44

ATmega-based Arduinos

ATmega168 microprocessors, 10

ATmega2560 microprocessors, 43

ATmega328 microprocessors, 10, 41–43, 94–95, 104–106, 187–189

ATmega32u4 microprocessors, 10–11, 43

power management functions, 108

sleeping, 108–113

ATtiny microcontrollers, 67

ATtiny44, 67–68

configuring, 70–72

connecting an Arduino Uno to an ATtiny for programming, 68–70

ATtinyCore, installing into the IDE, 70

Audio library, 33

AVR Dragon programmer, 52, 53

AVR processors, 41–44

AVR Studio, 51–53

avrdude, 50

avr/eeprom.h library, 135–137

B

band stop filtering, 243

base 10, 142

base 2, 142

BASIC, 260

batteries, 103–104

See also power management

baud rate, 190

bidirectional level converter modules, 155

binary, 141–142

and Arduino types, 142–143

bit banging, 157

bit manipulation, 177, 180

bits, 94, 141–142

least significant bit (LSB), 145

masking, 145–146

most significant bit (MSB), 145

shifting, 146–147

Blink sketch, 5–7

fast/slow blink, 20–22

modifying, 15–17

BLINK states, 266

boards

Adafruit Circuit Playground, 61–64

big Arduino boards, 12–13

ESP32-based boards, 66–67

I2C connections on, 156

NodeMCU, 64–66

non-Arduino boards, 59

overview, 10

power consumption, 101–103

small Arduino boards, 13

speed comparison, 86–87

suppliers, 283

Uno and similar boards, 10–11

unofficial, 14

Wemos D1 Mini, 64–66

Boards Manager, 60–61

bootloaders, 50–51

burning with AVR Studio and a programmer, 54–55

burning with the Arduino IDE and a second Arduino, 55–57

bypassing, 124

installing, 54

bumpy case, 17

bytes, 94, 142

C

C char arrays, 127–128

C language, 15

C precompiler directives, 45

camel case, 17

Capacitive Sensing library, 33

central processing unit (CPU), 41

char, 27, 142–143

character arrays, 26–27

circular buffers, 241–242

classes, 272

clocks, 70–71

reducing the clock speed, 104–106

See also real-time clock (RTC) module

code optimization, 123

commands, 36–37, 190–193

See also functions

comments, 15, 122–123

compiling, 50

constants, 124

cores, 44, 45

installing ATtinyCore into the IDE, 70

crystal oscillator, 71, 72

curly braces, 18, 19, 20, 32

current, 103–104

and clock speed, 106

See also power management

D

DACs, 240

Dallas Semiconductor. See 1-Wire bus standard

data direction register D (DDRD), 94–95, 98

data structures, 121–122

data types, 34–36

DDRB register. See data direction register D (DDRD)

delay, 16–17, 21–22, 262–263

DHCP, 213, 214, 215

Diecimila. See Arduino Uno

digital connections, 9–10

digital inputs, 22–24

fast digital input, 97–98

digital outputs, 24

basic code optimization, 92–93

controlling power with, 116–118

very fast digital output, 95–97

digital signal processing (DSP)

Arduino Due, 247–249

Arduino Uno, 245–247

averaging readings using circular buffers, 241–242

overview, 239–241

digital-to-analog converters. See DACs

digitization, 240

DS1307 real-time clock, 165–167

DS18B20 temperature sensor, 169, 173–175

See also 1-Wire bus standard

DSP. See digital signal processing (DSP)

Due. See Arduino Due

Duemilanove. See Arduino Uno

dweet.io, 233–234

See also Internet of Things (IoT)

Dynamic Host Configuration Protocol. See DHCP

dynamic memory, vs. static memory, 125–126

E

EEPROM, 41

avr/eeprom.h library, 135–137

example, 132–134

limitations, 137

overview, 131–132

EEPROM library, 33, 135

See also avr/eeprom.h library

Electrically Erasable Programmable Read Only Memory. See EEPROM

ENC28J60 chipset, 212

ESP32-based boards, 66–67

sleeping, 114–115

and WiFi, 229–232

ESP8266 WiFi microcontroller, 64–66

hardware interrupts, 74

sleeping, 113–114

WiFi example, 229–232

Ethernet

Arduino Ethernet, 212–213

Power over Ethernet (PoE), 213

wired Ethernet examples, 218–226

Ethernet library, 213

making a connection, 214–217

making requests, 217–218

setting up a web server, 216–217

Ethernet Shield, 212

EtherTen, 212–213

examples folder, 278

external interrupts, 111–113

F

Fast Fourier Transform (FFT), 253, 255–256

FFT algorithm, 253, 255–256

FFT library, 33

file extensions, 48–50

filtering, 243–245

filter code generation, 249–252

Firmata library, 33

flash memory, 137–139

minimizing usage, 123–124

storing string constants in, 122

floats, 87–89

for command, 20

Fourier Transform, 253–254

frequency measurement example, 256–257

spectrum analyzer example, 254–256

freeMemory function, 123

frequency, 239

frequency domain, 253, 254

frequency measurement example, 256–257

functions, 16, 20–22, 36–37

serial commands, 190–193

string functions, 131

WiFi-specific functions, 227–228

See also libraries

fuses, 71

G

GCC compiler, 50

getKey function, 208

getModifiers function, 208

getOemKey function, 208

GFX library, 33

gibberish sketch, 27

GitHub, 278, 279–282

GND connectors, 9

GPIOs, 9–10, 148–149

GPS module example, 199–202

H

hardware

1-Wire bus standard, 169–170

I2C, 155–156

networking, 211–213

serial communication, 187–189

SPI, 178–179

hardware interrupts, 73–76

header file, 275–276

hexadecimal, 45, 144

high-pass filtering, 243

I

I2C

connections on Arduino boards, 156

examples, 159–167

hardware, 155–156

initializing, 157

overview, 153–154

protocol, 156–157

receiving data, 158

sending data, 157–158

IDE

Boards Manager, 60–61

burning a bootloader with the IDE and a second Arduino, 55–57

installing, 4

installing ATtinyCore into the IDE, 70

libraries, 32–33

Library Manager, 33–34

loading Blink sketch, 5–7

preprocessor, 50

Serial Monitor, 24–26

if, 18–19

implementation file, 276–277

include statements, 32, 44

installation

of bootloader, 54–57

of IDE, 4

int, 17, 34, 46

Integrated Development Environment. See IDE

Interaction Design Institute, 39

Internet of Things (IoT), 211, 232

attaching the TMP36 temperature sensor, 235

displaying the temperature on a web page, 236–237

dweet.io, 233–234

programming the NodeMCU or Wemos D1 Mini, 234–235

See also WiFi

interrupt modes, 77

interrupt pins, 77

Interrupt Service Routines (ISRs), 76, 78–79, 80

interrupts, 73

enabling and disabling, 80

external interrupts, 111–113

hardware interrupts, 73–76

timer interrupts, 80–84

IOREF pin, 9

IoT. See Internet of Things (IoT)

ISRs. See Interrupt Service Routines (ISRs)

J

JavaScript Object Notation. See JSON web service

JSON web service, 223–226

K

keyboard emulation, 203–206

Keyboard library, 33

KeyboardController library, 208

keywords file, 277

Knight, Peter, 108

L

“L” LED, 5–7

language, 15

least significant bit (LSB), 145

LED backpack boards, 164–165

Leonardo. See Arduino Leonardo

LeoStick, 203

libraries, 32–34

adding from a ZIP file, 34

examples folder, 278

header file, 275–276

implementation file, 276–277

keywords file, 277

publishing on GitHub, 279–282

releasing, 278

TEA5767 radio example, 272–278

testing, 278

when to make a library, 271–272

See also specific libraries

Library Manager, 33–34, 278, 282

LiquidCrystal library, 33

loop function, 16–17, 19–20, 260–263

low-pass filtering, 243–245

M

MAC addresses, 214–215

main function, 47–48

main.cpp, 47–48

malloc command, 125, 126

masking bits, 145–146

master and slave concept, 170

Master In Slave Out (MISO), 178

Master Out Slave In (MOSI), 178

MaxSonar rangefinders, 193

MCP3008, 181–185

memory

capacities of Arduinos and Arduino compatibles, 121

EEPROM, 131–137

flash memory, 122, 123–124, 137–139

measuring free memory, 123

minimizing RAM usage, 121–123

overview, 119–121

SD card storage, 139–140

static vs. dynamic memory allocation, 125–126

strings, 127–131

MemoryFree library, 123

methods, 272

Micro, 13

microcontrollers, 41–44

microSD card slot, 139–140, 212

millis function, 263, 265

modifier keys, 205

most significant bit (MSB), 145

mouse emulation, 203–204, 206–207

Mouse library, 33

mouseDragged function, 209

mousePressed function, 209

mouseReleased function, 210

music controllers, 204

N

Nano, 13

Narcoleptic library, 108–111, 274

National Marine Electronics Association (NMEA), 199, 200

networking, hardware, 211–213

NG. See Arduino Uno

NodeMCU, 64–66

programming for Internet of Things, 234–235

nonvolatile flash memory, 8

O

OneWire library, 33, 170–173

See also 1-Wire bus standard

open-collector outputs, 155

oscillator, 72

P

paperclip sketch, 22–24

parasitic power, 169

pausing without blocking, 262–263

photoresistors, 116–118

pins, IOREF, 9

pins_arduino.h, 50

port input D (PIND), 94–95

PORTD register, 94–95

ports, ATmega328, 94–95

power connections, 9

power management

current and batteries, 103–104

power consumption of Arduino boards, 101–103

reducing the clock speed, 104–106

sleeping, 108–115

turning off features, 107–108

using digital outputs, 116–118

Power over Ethernet (PoE), 213

Power Supervision, 41–43

power supplies, 8, 72

private, vs. public, 272

Processing, 39

Program Memory (PROGMEM) directive, 138

programming for Arduino, 259–260

state diagrams, 265–266

programming language, 15

public, vs. private, 272

pull-up resistors, 78, 155

pulse-width modulation (PWM), 30–32, 82–84

PWM. See pulse-width modulation (PWM)

R

RAM, 119–121

measuring free memory, 123

minimizing usage, 121–123

random access memory (RAM), 41

real-time clock (RTC) module, 153, 154, 165–167

registers, 94–95

repositories, creating, 280–282

Reset connector, 9

Reset switch, 7

RTC. See real-time clock (RTC) module

RTClib library, 165–167

Rx pin, 187–188

S

SD card storage, 139–140

SD library, 33

semicolon (;), 16

Serial Clock Line (SCL), 156

serial communication

Arduino-to-Arduino example, 196–198

commands, 190–193

computer to Arduino over USB example, 194–196

GPS module example, 199–202

hardware, 187–189

overview, 187

protocol, 190

SoftwareSerial library, 193–194

UART, 188–189

serial data, 148–152

Serial Data Line (SDA), 156–157

Serial Monitor, 24–26

Serial Peripheral Interface. See SPI

Serial.println commands, 124

Servo library, 33

setup function, 16, 260

shifting bits, 146–147

Signal Generator, 245

See also digital signal processing (DSP)

sin function, 89–91

sine waves, 89–91

sizeof function, 126

sketches

ArduinoISP, 57, 69

Blink, 5–7, 15–17, 20–22

defined, 5

gibberish, 27

paperclip, 22–24

uploading, 17, 48–51

sleeping

ESP32-based boards, 114–115

ESP8266 WiFi microcontroller, 113–114

Narcoleptic library, 108–111

waking ATmega-based Arduinos on external interrupts, 111–113

SoftwareSerial library, 33, 193–194, 274

spectrum analyzer example, 254–256

speed

analog inputs, 98–100

Arduino Uno vs. Mac laptop, 85–86

ATmega328 ports, 94–95

basic code optimization, 92–93

comparing Arduino boards, 86–87

fast digital input, 97–98

sine waves, 89–91

using floats vs. longs, 87–88

very fast digital output, 95–97

SPI

configuration function, 181

connections on Arduino boards, 178

example, 181–185

hardware, 178–179

ICSP headers, 178–179

overview, 177

protocol, 179

SPI library, 33, 180–181

sprintf function, 128–129

starter kits, 285

state diagrams, 265–266

state machines, 266–269

static memory, vs. dynamic memory, 125–126

static RAM (SRAM), 41

Stepper library, 33

string constants, storing in flash memory, 122

strings, 27

Arduino String Object library, 130–131

C char arrays, 127–128

concatenating, 130–131

creating, 130

finding the length of, 129–130

formatting with multiple prints, 128

formatting with sprintf, 128–129

functions, 131

overview, 127

successive approximation ADCs, 99–100

suppliers, 284

boards, 283

components and modules, 284

starter kits, 285

System Clock (SCLK), 178

T

TEA5767 FM radio, 159–161, 272–278

receiver module, 153, 154

temperature sensors, 169, 173–175, 235

threads, 260

time domain, 253, 254

timer interrupts, 80–84

Timer library, 263–265

TimerOne library, 80–84

TMP36 temperature sensor, 235

toolchain, 48, 49

Transistor-Transistor Logic, 187

tri-state mode, 155

TTL Serial, 187, 189

See also serial communication

Two Wire Interface (TWI). See I2C

Tx pin, 187–188

U

UART, 188–189

See also serial communication

uint_8, 46

Universal Asynchronous Receiver Transmitter. See UART

Uno. See Arduino Uno

uploading sketches, 17, 48–51

USB ports, 204

USB programming

keyboard emulation, 203–206

mouse emulation, 203–204, 206–207

using the Arduino Due as a USB host, 207–210

V

variables, 17–18, 124

short variable names, 122

volatile, 79–80

voltage, 28–30

W

W5100 chip, 212

Watchdog Timer, 41–43

web servers

physical web server example, 218–223

setting up, 216–217

web service, JSON, 223–226

Wemos D1 Mini, 64–66

programming for Internet of Things, 234–235

WiFi, 211

Arduino WiFi example, 228–229

ESP8266/ESP32 WiFi example, 229–232

See also Internet of Things (IoT)

WiFi library, 227–228

WiFi Shield, 213

WiFi-specific functions, 227–228

Wire library, 33, 157–158

wired Ethernet

JSON web service example, 223–226

physical web server example, 218–223

Wiring, 39, 44–48

wiring.c, 48

WProgram.h (Wiring Program), 44

X

Xbee library, 33