Index

Symbols

& (ampersand) reference operator, 164, 170

* (asterisk) dereference operator, 164

retrieving data, 166-167

storing data, 167

-> operator, retrieving data structure values with pointers, 174-176

; (semicolon), terminating statements, 77

Numbers

-3 header socket port, 66

-5 header socket port, 66

-6 header socket port, 66

-9 header socket port, 66

-10 header socket port, 66

-11 header socket port, 66

2 header socket port, 66

3.3V header socket port, 65

4 header socket port, 66

5V header socket port, 65

7 header socket port, 66

8 header socket port, 66

12 header socket port, 66

13 header socket port, 66

A

A0 header socket port, 65

A1 header socket port, 65

A2 header socket port, 65

A3 header socket port, 65

A4 header socket port, 65

A5 header socket port, 65

abs() function, 85

accessing header sockets, 66

accessories, 17-18

activating serial monitor, 53

Adafruit Data Logging shield, 376

ADC (analog-to-digital converter), 25, 236

Add File option (Sketch menu), 46

addition operator, 80

advanced math functions, 85

alphanumeric LCD devices, 319-320

ALU (Arithmetic Logic Unit), 24

ampersand (&) reference operator, 164, 170

analog interfaces

input signals

detecting, 236

limiting values, 241

mapping values, 242-245, 292

potentiometer example sketch, 238-241

reference voltage changes, 245-246

layouts, 237-238

output signals, generating, 236-237, 246-247

planning, 389-390

analog output, 26

analog sensors, 287-288

resistance-based sensors, 295-297

temperature LCD display example sketch, 327-329, 333-335

temperature logging example sketch, 382-384

temperature monitor example project

analog interfaces, 389-390

breadboard circuits, 393-394

components needed, 391-392

digital interfaces, 390-391

planning, 388-389

planning sketches, 394-395

schematics, 392

testing sketches, 398-399

writing sketches, 395-398

temperature sensors for web servers, 361-364

touch sensors, 297-300

voltage-based sensors, 288-293

converting voltage values, 292-293

sensitivity of, 291-292

temperature detection example sketch, 293-295

voltage levels, 288-291

analogRead() function, 238, 291

analogReference() function, 245-246, 291

analog-to-digital converter (ADC), 25, 236

analogWrite() function, 246, 307

AND operator, 80, 97

architecture of Arduino, 9-11

Archive Sketch option (Tools menu), 47

Arduino

accessories, 17-18

analog interfaces. See analog interfaces

architecture, 9-11

communication between units, 280-284

controlling from web browser, 364-370

defined, 7

digital interfaces. See digital interfaces

history of, 11-12

interrupts

external interrupts, 252-253, 254-260

ignoring, 264-265

pin change interrupts, 253-254, 260-262

polling versus, 251-252

timer interrupts, 254, 262-264

memory

comparison among types, 181-182

creating dynamic variables, 185-189

EEPROM memory, 194-197

flash memory, 189-193

SRAM memory, 183-185

as microcontroller, 7-8

models. See models of Arduino

powering on/off with USB hub, 69

shields. See shields

trademark protection, 9

Arduino IDE, 31-32

console window, 49-50

downloading, 32-33

Edit menu commands, 44-46

editor window, 59-60

File menu commands, 40-43

Help menu commands, 48

installing

for Linux, 37

for OS X, 36-37

for Windows, 33-36

interface, 39-40

libraries, 201

compiling functions, 205

components of, 202

contributed libraries, 206-208

documentation, 205

example usage, 205-206, 212-214

including, 204

installing, 212

location, 202-203

referencing functions in, 204-205

standard libraries, list of, 203-204

troubleshooting, 213

zip file creation, 211-212

message area, 49-50

serial monitor, 52-54

setup, 51-52

shield libraries, 32

Sketch menu commands, 46

toolbar, 49

Tools menu commands, 46-48

Arduino programming language. See also C programming language

functions, 83-86

advanced math functions, 85

bit manipulation functions, 86

calling, 148-150

defining, 148

global variables, 155-156

local variables, 156-158

passing values to, 152-154

random number generators, 86

recursive functions, 158-160

returning values, 150-152

scope of variables, 154

Serial class, 83-84

time functions, 84-85

troubleshooting, 148

user-defined, 147

strings, 126-129

creating and manipulating, 126-128

manipulating, 130-131

String object methods, 128-129

Arduino Starter Kit, 18

AREF header socket port, 66

arguments, 152

Arithmetic Logic Unit (ALU), 24

arrays

creating, 110-111

of data structures, 140-142

defined, 120

loops, 109-112

pointer arithmetic, 168-171

sizing, 111-112, 121-122

strings, 120-126

comparing, 125-126

creating, 121-122

functions for, 122-125

ASCII format, 119, 271

assembly language, 27-28

assigning values

to data structures, 136-138

to variables, 77

assignment statements

equality comparison versus, 96

equations versus, 82

asterisk (*) dereference operator, 164

retrieving data, 166-167

storing data, 167

ATmega AVR microcontrollers, 9-10

components of, 23-26

CPU, 24-25

EEPROM memory, 194-197

flash memory, 189-193

I/O interface, 25-26

memory, 25

memory comparisons, 181-182

SRAM memory, 183-185

instruction set, downloading, 27

Atmel C library, 29-30

Atmel Studio package, 30

attach() function, 313

attached() function, 313

attachInterrupt() function, 254-255

Auto Format option (Tools menu), 47

autoscroll() function, 325

Autoscroll option (serial monitor), 53

available() function

Serial library, 270

Wire library, 278

available method

EthernetClient class, 343

EthernetServer class, 345

EthernetUDP class, 347

File class, 377

AVR Libc project, 29

avr-gcc package, 30

B

baud rate, 271

Baud Rate option (serial monitor), 54

begin() function

LiquidCrystal library, 325

Serial library, 83, 270-271

SPI library, 276

Wire library, 278

begin method

Ethernet class, 340

EthernetServer class, 345

EthernetUDP class, 347

SD class, 376

beginPacket method, 347

beginTransmission() function, 278

beta software, 33

binary calculations, 81

bit() function, 86

bit manipulation functions, 86

bitClear() function, 86

bitRead() function, 86

bitSet() function, 86

bitwise AND operator, 80

bitwise OR operator, 80

bitWrite() function, 86

blink() function, 325

blinking LED example sketch, 272-274, 280-284

Board option (Tools menu), 47

Boolean comparisons, 96-97

boolean data type, 77

Boolean logic, 81

bootloader, 42

functions in, 57-58

uploading, 48

breadboards, 17

creating circuits, 393-394

electronic circuit interfaces, 67-68

break statements, 99, 113-114

browsers, controlling Arduino from, 364-370

brushes in DC motors, 304

buffer overflow, 184

building

libraries

code file creation, 208-210

example usage, 212-214

header file creation, 210-211

installing, 212

zip file creation, 211-212

web servers, 361-364, 366-370

Burn Bootloader option (Tools menu), 48

byte data type, 77

C

C programming language, 28-29. See also Arduino programming language

Arduino IDE, 31-32. See also Arduino IDE

Atmel C library, 29-30

data structures, 133-134

arrays of, 140-142

assigning values, 136-138

copying, 138-140

creating, 134-136

initializing, 176

loops, 103-104

arrays, 109-112

break statements, 113-114

continue statements, 114-116

do-while statements, 106-107

endless loops, 106

multiple variables in, 112

nesting, 112-113

for statements, 107-109

while statements, 104-106

operators

compound operators, 82

math operators, 80-82

order of operations, 82

pointers, 163-166

arithmetic with arrays, 168-171

data structures and, 173-176

null pointers, 167-168

passing to functions, 176-178

printing, 166

referencing strings, 172-173

retrieving data, 166-167

storing data, 167

string manipulation, 171-172

void pointers, 168

shield libraries, 32

statements, terminating, 77

strings, 120-126

comparing, 125-126

creating, 121-122

functions for, 122-125

structured commands

comparisons, 95-97

compound conditions, 97

else if statements, 93-95

else statements, 92-93

grouping multiple statements, 90-92

if statements, 89-90

negating condition checks, 98

switch statements, 98-99

unions, 142-145

variables

assigning values, 77

data types, 77-78

declaring, 76-77

dynamic variables, 185-189

qualifiers, 79

scope, 80

C++ programming language, library creation

code files, creating, 208-210

header files, creating, 210-211

calculating factorials, 158-160

calling functions, 148-150, 158-160. See also referencing

calloc() function, 186-187

camel case, 77

CapacitiveSensor library, 298-300

capacitors, 297-298

capacity classes (SD cards), 374

case statements, 99

CHANGE external interrupt mode, 255

changing

dynamic variables, 187

reference voltages, 245-246, 290-291

char data type, 77, 79, 119-120

character arrays. See arrays, strings

charAt method, 128

chat server example sketch, 349-351

circuits. See electronic circuits

clear() function, 325

Client class. See EthernetClient class

clock speed, 25, 277

close method, 377

Close option (File menu), 42

code files in libraries, 202, 208-210

code libraries, 29

code listings. See listings

coding. See programming microcontrollers

color types (LCDs), 320-321

comma-separated values (CSV) format, 380

Comment/Uncomment option (Edit menu), 45

communication

LCD (liquid crystal display) devices, 319

Arduino interface connections, 323-325

color types, 320-321

display types, 319-320

downloading and installing LCD shield library, 330-331

interface pins, 321-323

LCD shield, 329-330

LCD shield connections, 332-333

LCD shield library functions, 331-332

LiquidCrystal library, 325-327

temperature display example sketch, 327-329, 333-335

troubleshooting, 329

serial communication protocols, 267-268

I2C (Inter-Integrated Circuit) protocol, 277-284

serial ports, 268-274

SPI (Serial Peripheral Interface) protocol, 274-277

compareTo method, 128

comparisons, 95-97

Boolean comparisons, 96-97

compound conditions, 97

negating condition checks, 98

numeric comparisons, 95-96

string comparisons, 96, 125-126

compilers, 28

compiling

functions in standard libraries, 205

sketches, 60-61

compound conditions, 97

compound operators, 82

concat method, 128

configuring Arduino IDE, 51-52

connect method, 343

CONNECT method token, 357

connected method, 343

connections. See also interfaces

with Ethernet shield, 18-19

with LCD devices, 323-325

with LCD shield, 332-333

console window (Arduino IDE), 49-50

const variable qualifier, 79

constants, 79

in flash memory, 190-191

memory locations, 184

constrain() function, 85, 241

continue statements, 114-116

contrast on LCD devices, 329

contributed libraries, 206-208. See also building libraries

controllers, 24

converting voltage values in analog sensors, 292-293

Copy as HTML option (Edit menu), 44

Copy for Forum option (Edit menu), 44

Copy option (Edit menu), 44

copying

data structures, 138-140

strings, 125, 171-172

cos() function, 85

.cpp file extension, 202

CPU

components of, 24-25

programming

assembly language, 27-28

C programming language, 28-29. See also C programming language

machine code, 26

createChar() function, 325

CSV (comma-separated values) format, 380

current sinks, digital interfaces as, 222-223

current sources, digital interfaces as, 222-223

cursor() function, 325

Cut option (Edit menu), 44

D

DAC (digital-to-analog converter), 236-237

data display with LCD shield, 19

data pointers. See pointers

data registers, 24

data structures, 133-134

arrays of, 140-142

assigning values, 136-138

copying, 138-140

creating, 134-136

initializing, 176

pointers and, 173-176

data types, 77-78, 190-191

DC motors, 303-304

direction control, 307-308

powering on/off, 305-306, 308-311

speed control, 306-307, 311-313

debugging sketches, 83. See also troubleshooting

declaring. See also defining

flash memory data types, 190-191

local variables, 156-158

variables, 76-77

Decrease Indent option (Edit menu), 45

decrement operator, 80

default statements, 99

#define directive, 210

defining. See also declaring

dynamic variables, 186-187

functions, 148

global variables, 155-156

delay() function, 84

delayMicroseconds() function, 84

DELETE method token, 357

dereference operators, 164

retrieving data, 166-167

storing data, 167

detach() function, 313

detachInterrupt() function, 255

DHCP (Dynamic Host Configuration Protocol), 342-343

digital interfaces

input voltage levels, 226-229

interface 13, 229

interrupts

external interrupts, 252-260

ignoring, 264-265

pin change interrupts, 253-254, 260-262

polling versus, 251-252

timer interrupts, 254, 262-264

layouts, 220-221

LCD (liquid crystal display) devices, 323-325

number of, 219-220

output voltage levels, 221-223

planning, 390-391

setting input/output modes, 221

SPI signals, 276

traffic signal example sketch, 223-226, 229-231, 364-370

troubleshooting

input voltage levels, 227

with serial monitor, 226

digitalRead() function, 226

digital-to-analog converter (DAC), 236-237

digitalWrite() function, 63, 221

direction of DC motors, controlling, 307-308

display() function, 325

display types (LCDs), 319-320

displaying

data with LCD shield, 19

strings, 122

division operator, 80

documentation for standard libraries, 205

double data type, 77

do-while statements, 106-107

downloading

Arduino IDE, 32-33

ATmega AVR microcontroller instruction set, 27

contributed libraries, 206-208

LCD shield library, 330-331

Timer One library, 263

drivers, installing, 34-35

Due model, 13

analog interfaces, 236

digital interfaces, 219

I2C interface pins, 278

serial port interfaces, 269

voltage levels, 288

durability of SD cards, 375

Dynamic Host Configuration Protocol (DHCP), 342-343

dynamic IP addresses, 342-343

dynamic variables, 184-189

changing, 187

defining, 186-187

example usage, 187-189

removing, 187

E

Eagle circuit board software, 400-401

Edit menu commands, 44-46

editor window (Arduino IDE), creating sketches, 59-60

EEPROM Extended library, 197

EEPROM library, 203

EEPROM memory, 25, 194-197

comparison with SRAM and flash memory, 181-182

example usage, 195-197

including library, 194-195

retrieving data, 196-197

EEPROMex library, 197

electronic circuits

analog sensors in, 287-288

resistance-based sensors, 295-297

temperature LCD display example sketch, 327-329, 333-335

temperature logging example sketch, 382-384

temperature sensors for web servers, 361-364

touch sensors, 297-300

voltage-based sensors, 288-295

breadboard circuits, creating, 393-394

for DC motors

powering on/off, 308-311

speed control, 311-313

interfacing with sketches, 64-69

adding to projects, 68-69

analog output generation, 246-247

blinking LED example sketch, 272-274, 280-284

breadboards, 67-68

external interrupts, 255-260

header socket usage, 64-66

input mapping, 242-245

pin change interrupts, 261-262

potentiometer example sketch, 238-241

traffic signal example sketch, 223-226, 229-231, 364-370

prototype circuit boards, creating, 399-401

for servo motors, 314-316

electronically erasable programmable read-only memory. See EEPROM memory

else if statements, 93-95

else statements, 92-93

enabling external interrupts, 254-255

end() function

Serial library, 270

SPI library, 276

#endif directive, 210

endless loops, 106

endPacket method, 347

endsWith method, 128

endTransmission() function, 278

equality comparison, assignment statements versus, 96

equals method, 128

equalsIgnoreCase method, 128

equations, assignment statements versus, 82

Esplora library, 203

Esplora model, 14

Ethernet class, 340-341

Ethernet library, 203

Ethernet model, 15, 278, 339

Ethernet shield, 18-19, 337-338

Ethernet Shield library, 340

chat server example sketch, 349-351

dynamic IP addresses, 342-343

Ethernet class, 340-341

EthernetClient class, 343-345

EthernetServer class, 345-347

EthernetUDP class, 347-349

IPAddress class, 341-342

EthernetClient class, 340, 343-345

EthernetServer class, 340, 345-347

EthernetUDP class, 340, 347-349

events, serial, 274

example sketches, modifying, 41

Examples option (File menu), 41

exFAT file format, 374

exists method, 376

external interrupts, 252-253

enabling, 254-255

traffic signal example sketch, 255-260

external memory, 182

external power sources, 17, 69

external reference voltages, 246

F

factorials, calculating, 158-160

FALLING external interrupt mode, 254

FAT16 file format, 374

File class, 376-378

file extensions for sketches, 41

file formats for SD cards, 374

File menu commands, 40-43

files on SD cards

reading, 379-380

writing to, 379

find() function, 10

Find Next option (Edit menu), 45

Find option (Edit menu), 45

Find Previous option (Edit menu), 46

finding serial ports in Windows, 52

findUntil() function, 270

Fio model, 288

Firmata library, 203

Fix Encoding and Reload option (Tools menu), 47

flash memory, 25, 189-193

comparison with SRAM and EEPROM, 181-182

data types, 190-191

example usage, 192-193

retrieving data, 191-192

float data type, 77

floating-point values, integer values versus, 78

flow control. See loops; structured commands

flush() function, 270

flush method

EthernetClient class, 343

File class, 377

flushing SD card data, 378

folders on SD cards, 381-382

for statements, 107-109, 112

formatting sketches, 91

free() function, 187

functions

in Arduino, 83-86

advanced math functions, 85

bit manipulation functions, 86

calling, 148-150

defining, 148

global variables, 155-156

local variables, 156-158

passing values to, 152-154

random number generators, 86

recursive functions, 158-160

returning values, 150-152

scope of variables, 154

Serial class, 83-84

time functions, 84-85

troubleshooting, 148

user-defined, 147

in bootloader, 57-58

compiling in standard libraries, 205

in EEPROM memory, 194

for flash memory access, 191

LCD shield library, 331-332

LiquidCrystal library, 325-326

passing pointers to, 176-178

private functions, 211

public functions, 211

referencing in standard libraries, 204-205

Serial library, 269-272

Servo library, 313

SPI library, 276-277

for strings, 122-125

testing results, 97

Wire library, 278-280

G

gate leads in transistors, 305

GET method token, 357

getBytes method, 128

global variables, 80

defining, 155-156

memory locations, 184

overriding, 158

GND header socket ports, 65-66

graphical LCD devices, 319-320

grounding analog sensors, 290

grouping multiple statements

in else statements, 92

in if statements, 90-92

GSM library, 203

H

.h file extension, 202

hardware

external interrupts, 252-253

open source hardware, 9

H-bridges, 307-308

HD44780 controller chips, 321-322

HEAD method token, 357

header files in libraries, 202, 210-211

header sockets, 10-11

accessing, 66

electronic circuit interfaces, 64-66

on Uno R3 unit, 15-16

headers (HTTP)

request headers, 358

response header lines, 360-361

heap data area, 183-185

dynamic variables, 185-189

changing, 187

defining, 186-187

example usage, 187-189

removing, 187

Help menu commands, 48

highByte() function, 86

high-current devices, digital interface connections, 221-223

higher-level programming languages, 28-29

history of Arduino, 11-12

home() function, 325

HTML in sketches, 44

HTTP (Hypertext Transfer Protocol), 355

requests, 356-358

request headers, 358

request line, 357

responses, 358-361

response header lines, 360-361

status line, 358-360

sessions, 355-356

I

I2C (Inter-Integrated Circuit) protocol, 277-284

blinking LED example sketch, 280-284

interfaces, 278

Wire library functions, 278-280

ICSP (in-circuit serial programming) header, 390

IDE (integrated development environment)

Arduino IDE, 31-32

console window, 49-50

downloading, 32-33

Edit menu commands, 44-46

editor window, 59-60

File menu commands, 40-43

Help menu commands, 48

interface, 39-40

Linux installation, 37

message area, 49-50

OS X installation, 36-37

serial monitor, 52-54

setup, 51-52

shield libraries, 32

Sketch menu commands, 46

toolbar, 49

Tools menu commands, 46-48

Windows installation, 33-36

Atmel Studio package, 30

if statements, 89-90

compound conditions, 97

grouping multiple statements, 90-92

negating condition checks, 98

#ifndef directive, 210

ignoring interrupts, 264-265

Import Library option (Sketch menu), 46

importing. See also installing

contributed libraries, 206-208

PinChangeInt library, 260-261

Timer One library, 263

in-circuit serial programming (ICSP) header, 390

#include directive, 58-59, 204

Ethernet Shield library, 340

header files, 208

including libraries, 58-59

EEPROM memory, 194-195

standard libraries, 204

Increase Indent option (Edit menu), 45

increment operator, 80

index values (arrays), 110

indexOf method, 128

initializing data structures, 176

input flapping, 227-228

INPUT interface mode setting, 221

input mode

for analog interfaces

detecting signals, 236

limiting values, 241

mapping values, 242-245, 292

potentiometer example sketch, 238-241

reference voltage changes, 245-246

for digital interfaces

setting, 221

traffic signal example sketch, 229-231

voltage levels, 226-229

INPUT_PULLUP interface mode setting, 221, 228-229

installing. See also importing

Arduino IDE

for Linux, 37

for OS X, 36-37

for Windows, 33-36

drivers, 34-35

LCD shield library, 330-331

libraries, 212

instruction set, 26-27

int data type, 77, 79

integer values, floating-point values versus, 78

integrated development environment (IDE). See IDE (integrated development environment)

interface 13 as input, 229

interfaces, 10-11. See also electronic circuits

analog interfaces. See also analog sensors

input signals, detecting, 236

layouts, 237-238

limiting input values, 241

mapping input values, 242-245, 292

output signals, generating, 236-237, 246-247

planning, 389-390

potentiometer input example sketch, 238-241

reference voltage changes, 245-246

Arduino IDE, 39-40

digital interfaces

input voltage levels, 226-229

interface 13, 229

layouts, 220-221

number of, 219-220

output voltage levels, 221-223

planning, 390-391

setting input/output modes, 221

traffic signal example sketch, 223-226, 229-231

troubleshooting, 226

I2C (Inter-Integrated Circuit) protocol, 278

interrupts

external interrupts, 252-260

ignoring, 264-265

pin change interrupts, 253-254, 260-262

polling versus, 251-252

timer interrupts, 254, 262-264

I/O interface, 25-26

LCD (liquid crystal display) devices

Arduino interface connections, 323-325

interface pins, 321-323

LCD shield connections, 332-333

SD cards, 375-376

serial port interfaces, 268-269

sketches with electronic circuits, 64-69

adding to projects, 68-69

breadboards, 67-68

header socket usage, 64-66

SPI (Serial Peripheral Interface) protocol, 274-276

on Uno R3 unit, 15

Inter-Integrated Circuit (I2C) protocol, 277-284

blinking LED example sketch, 280-284

interfaces, 278

Wire library functions, 278-280

internal reference voltages, 245-246

interrupt service routine (ISR), 252, 255

interrupts

external interrupts, 252-253

enabling, 254-255

traffic signal example sketch, 255-260

ignoring, 264-265

pin change interrupts, 253-254

importing PinChangeInt library, 260-261

traffic signal example sketch, 261-262

polling versus, 251-252

timer interrupts, 254

importing Timer One library, 263

testing, 263-264

interrupts() function, 264-265

I/O interface in ATmega AVR microcontrollers, 25-26

IOREF header socket port, 65

IP addresses

dynamic IP addresses, 342-343

static addresses, 341-342

IPAddress class, 340-342

isDirectory method, 377

ISR (interrupt service routine), 252, 255

K–L

kits, 18

lastIndexOf method, 128

LCD (liquid crystal display) devices, 319

Arduino interface connections, 323-325

color types, 320-321

display types, 319-320

interface pins, 321-323

LCD shield, 329-330

connections, 332-333

downloading and installing library, 330-331

library functions, 331-332

LiquidCrystal library

example usage, 327

functions, 325-326

temperature display example sketch, 327-329, 333-335

troubleshooting, 329

LCD shield, 19, 329-330

connections, 332-333

downloading and installing library, 330-331

library functions, 331-332

temperature display example sketch, 333-335

LDR (light-dependent resistor), 296

LEDs

resistors and, 256

traffic signal example sketch. See traffic signal example sketch

on Uno R3 unit, 16-17

WiFi shield, 339

left shift operator, 80

leftToRight() function, 325

legal issues, trademark protection of Arduino name, 9

length method, 128

Leonardo model, 13

analog interfaces, 236

digital interfaces, 219

external interrupts, 253

I2C interface pins, 278

libraries, 201

building

code file creation, 208-210

example usage, 212-214

header file creation, 210-211

installing, 212

zip file creation, 211-212

components of, 202

contributed libraries, 206-208

including, 58-59, 194-195

location, 202-203

standard libraries

compiling functions, 205

documentation, 205

example usage, 205-206

including, 204

list of, 203-204

referencing functions in, 204-205

troubleshooting, 213

light meter example sketch, 296-297

light sources for LCDs, 320-321

light-dependent resistor (LDR), 296

LilyPad model, 15

limiting analog input values, 241

Linux, Arduino IDE installation, 37

liquid crystal display. See LCD (liquid crystal display) devices

LiquidCrystal library, 203

example usage, 327

functions, 325-326

temperature display example sketch, 327-329

listings

sketch0401 code, 59

sketch0602 code, 94

local variables, 80, 156-158

localIP method, 340

location of libraries, 202-203

logic flow control. See loops; structured commands

logical AND operator, 80, 97

logical NOT operator, 80, 98

logical OR operator, 80, 97

long data type, 77, 79

loop function, 58

loops, 103-104

arrays, 109-112

break statements, 113-114

continue statements, 114-116

do-while statements, 106-107

endless loops, 106

nesting, 112-113

for statements, 107-109, 112

while statements, 104-106

LOW external interrupt mode, 255

lowByte() function, 86

low-current devices, digital interface connections, 221-223

M

MAC (Media Access Control) addresses, 341

machine code, 26

maintain method, 340

malloc() function, 186-187

map() function, 85, 242-245, 292

mapping

analog input values, 242-245, 292

LCD interface pins, 323-325

master mode (SPI), 274

math operators, 80-82

max() function, 85

Media Access Control (MAC) addresses, 341

Mega model, 13

analog interfaces, 236

digital interfaces, 219

external interrupts, 253

I2C interface pins, 278

serial port interfaces, 269

memory

in ATmega AVR microcontrollers, 9-10, 25

comparison among types, 181-182

creating dynamic variables, 185-189

EEPROM memory, 194-197

flash memory, 189-193

SRAM memory, 183-185

pointers. See pointers

variables. See variables

memory address wrap, 195

memory collisions, 185

memory leaks, 185

menu bar

Edit menu commands, 44-46

File menu commands, 40-43

Help menu commands, 48

Sketch menu commands, 46

Tools menu commands, 46-48

message area (Arduino IDE), 49-50

metal-oxide-semiconductor field-effect transistor (MOSFET), 306

method tokens (HTTP), 357

methods

Ethernet class, 340

EthernetClient class, 343

EthernetServer class, 345

EthernetUDP class, 347

File class, 377-378

SD class, 376-377

String object methods

comparison, 128-129

manipulation, 130-131

Micro model, 14

analog interfaces, 236

digital interfaces, 219

microcontrollers

ATmega AVR microcontrollers, 9-10

components of, 23-26

EEPROM memory, 194-197

flash memory, 189-193

memory comparisons, 181-182

SRAM memory, 183-185

block diagram, 8, 24

defined, 7-8

programming

Arduino programming language. See Arduino programming language

assembly language, 27-28

C programming language, 28-29. See also C programming language

machine code, 26

micros() function, 84

Micro-SD breakout board, 376

millis() function, 84

min() function, 85

Mini model

analog interfaces, 236

digital interfaces, 219

missing libraries, troubleshooting, 213

mkdir method, 376, 381

models of Arduino, 12-15

digital interfaces, number of, 219-220

Due, 13

Esplora, 14

Ethernet, 15, 339

Leonardo, 13

LilyPad, 15

Mega, 13

Micro, 14

Uno, 12-13, 15-17

Yun, 14-15

modifying example sketches, 41

modulus operator, 80

MOSFET (metal-oxide-semiconductor field-effect transistor), 306

motor shield, 19, 316

motors, 18

DC motors, 303-304

direction control, 307-308

powering on/off, 305-306, 308-311

speed control, 306-307, 311-313

servo motors, 304

positioning example sketch, 314-316

Servo library, 313-314

stepper motors, 304

multiple statements, grouping

in else statements, 92

in if statements, 90-92

multiple variables in for statements, 112

multiplication operator, 80

multi-user environments, 207

N

name method, 377

naming conventions

constants, 79

variables, 76-77

negating condition checks, 98

negative LCD displays, 320-321

nesting loops, 112-113

network connectivity

with Ethernet shield, 18-19, 337-338

chat server example sketch, 349-351

dynamic IP addresses, 342-343

Ethernet class, 340-341

Ethernet Shield library, 340

EthernetClient class, 343-345

EthernetServer class, 345-347

EthernetUDP class, 347-349

IPAddress class, 341-342

with HTTP, 355

requests, 356-358

responses, 358-361

sessions, 355-356

web browsers, controlling Arduino from, 364-370

web servers, building, 361-364

with WiFi shield, 339

New icon (toolbar), 49

New option (File menu), 40

Newline option (serial monitor), 54

noAutoscroll() function, 325

noBlink() function, 325

noCursor() function, 325

noDisplay() function, 325

nointerrupts() function, 264

NOT operator, 80, 98

NULL label, 167-168

null pointers, 167-168

null-terminated strings, 120

numeric comparisons, 95-96

O

onReceive() function, 278

onRequest() function, 278

Open icon (toolbar), 49

open method, 376, 382

Open option (File menu), 41

open source hardware, 9

openNextFile method, 377

operators

compound operators, 82

math operators, 80-82

numeric comparisons, 95

order of operations, 82

pointer operators, 164

OPTIONS method token, 357

OR operator, 80, 97

order of operations, 82

OS X

Arduino IDE installation, 36-37

zip file creation, 212

out of memory errors, troubleshooting, 186

OUTPUT interface mode setting, 221

output mode

for analog interfaces

generating signals, 236-237, 246-247

reference voltage changes, 245-246

for digital interfaces

setting, 221

traffic signal example sketch, 223-226

voltage levels, setting, 221-223

output of serial ports

Serial class functions, 83-84

viewing, 63

overflowing

LCD displays, 327

strings values, 122

overriding global variables, 158

P

Page Setup option (File menu), 43

parameters, 152

parseFloat() function, 270, 272

parseInt() function, 270, 272

parsePacket method, 347

passing to functions

pointers, 176-178

values, 152-154

Paste option (Edit menu), 45

PCB (printed circuit board), 67

peek() function, 270

peek method, 377

personal libraries, location of, 203

pgm_read_byte() function, 191

pgm_read_word() function, 191

pgmspace.h library, 191

photoresistor example sketch, 296-297

pin change interrupts, 253-254

importing PinChangeInt library, 260-261

traffic signal example sketch, 261-262

PinChangeInt library, 253, 260-261

pinMode() function, 221

planning projects, 387-389

analog interfaces, 389-390

breadboard circuits, 393-394

components needed, 391-392

digital interfaces, 390-391

schematics, 392

sketches, 394-395

PoE (Power over Ethernet), 338

pointers, 163-166

arithmetic with arrays, 168-171

data structures and, 173-176

null pointers, 167-168

passing to functions, 176-178

printing, 166

referencing strings, 172-173

retrieving data, 166-167

storing data, 167

string manipulation, 171-172

void pointers, 168

polling, interrupts versus, 251-252

ports

lower header sockets, 65

upper header socket, 66

position method, 377

positioning servo motors example sketch, 314-316

positive LCD displays, 320-321

POST method token, 357

potentiometer example sketch

input mapping, 242-245

input mode, 238-241

servo motors, 314-316

pow() function, 85

power, external sources, 17

Power over Ethernet (PoE), 338

powering on/off

Arduino with USB hub, 69

DC motors, 305-306, 308-311

precedence in mathematical operations, 82

Preferences option (File menu), 43

print() function

LiquidCrystal library, 325

Serial library, 63, 83, 270-271

print method

EthernetClient class, 343

EthernetServer class, 345

File class, 377

Print option (File menu), 43

printed circuit board (PCB), 67

printing pointers, 166

println() function, 83, 270-271

println method

EthernetClient class, 343

EthernetServer class, 345

File class, 377

private functions, 211

Pro model, 288

processors on ATmega AVR microcontrollers, 9-10

prog_char flash data type, 190

prog_int16_t flash data type, 190

prog_int32_t flash data type, 190

prog_uchar flash data type, 190

prog_uint16_t flash data type, 190

prog_uint32_t flash data type, 190

PROGMEM keyword, 190

program counters, 24

Programmer option (Tools menu), 47

programming microcontrollers

Arduino programming language. See Arduino programming language

assembly language, 27-28

C programming language, 28-29. See also C programming language

machine code, 26

programs. See sketches

project development

breadboards, creating circuits, 393-394

prototype circuit boards, creating, 399-401

with Prototype shield, 20

requirements

for analog interfaces, 389-390

components needed, 391-392

determining, 387-389

for digital interfaces, 390-391

schematics, creating, 392

sketches

planning, 394-395

testing, 398-399

writing, 395-398

prototype circuit boards, creating, 399-401

Prototype shield, 20, 399-400

public functions, 211

pulldown circuits, 228

pullup circuits, 228-229

PUT method token, 357

PuTTY package, 351

PWM (pulse-width modulation), 26, 237, 246, 306-307, 311-313

Q

qualifiers for variables, 79

Quit option (File menu), 43

quotes for characters and strings, 121

R

random() function, 86

random number generators, 86

randomSeed() function, 86

RC circuits, 298

read() function

EEPROM library, 194

Serial library, 270, 272

Servo library, 313

Wire library, 278

read method

EthernetClient class, 343

EthernetUDP class, 347

File class, 377

readButtons() function, 331

readBytes() function, 270, 272

readBytesUntil() function, 270, 272

reading files on SD cards, 379-380

realloc() function, 187

recursive functions, 158-160

Redo option (Edit menu), 44

reference operators, 164, 170

reference voltages, changing, 245-246, 290-291

referencing. See also calling functions

Ethernet Shield library, 340

functions in standard libraries, 204-205

strings with pointers, 172-173

reformatting SD cards, 374

relays, 305

remoteIP method, 347

remotePort method, 347

remove method, 376

removing dynamic variables, 187

replace method, 128

request headers (HTTP), 358

request line (HTTP requests), 357

requestFrom() function, 278

requests (HTTP), 356-358

request headers, 358

request line, 357

requirements, determining, 387-389

for analog interfaces, 389-390

components needed, 391-392

for digital interfaces, 390-391

reserve method, 128

Reset button on Uno R3 unit, 17, 92

RESET header socket port, 65

resistance-based analog sensors, 295-297

resistors, 17, 223

LEDs and, 256

in motor circuits, 306

in RC circuits, 297-298

as voltage dividers, 289-290

response header lines (HTTP), 360-361

responses (HTTP), 358-361

response header lines, 360-361

status line, 358-360

restarting sketches, 64, 92

retrieving data

from EEPROM memory, 196-197

from flash memory, 191-192

with pointers, 166-167, 173-176

with serial ports, 272

return code (functions), testing, 97

return statement, 150

returning values

from functions, 150-152

in pointers, 178

rewindDirectory method, 377

right shift operator, 80

rightToLeft() function, 325

RISING external interrupt mode, 254

rmdir method, 376, 382

Robot_Control library, 203

RS-232 serial interfaces, 269

running sketches, 63-64

RX <- 0 header socket port, 66

S

Save As option (File menu), 42

Save icon (toolbar), 49

Save option (File menu), 42

saving text editor files, 210

schematics, creating, 392

scope of variables, 80

in functions, 154

global variables, 155-156

local variables, 156-158

scrollDisplayLeft() function, 325

scrollDisplayRight() function, 325

SD cards

files

reading, 379-380

writing to, 379

folder organization, 381-382

interfaces, 375-376

SD library, 376-378

File class methods, 377-378

SD class methods, 376-377

specifications, 373-375

temperature logging example sketch, 382-384

SD class, 376-377

SD library, 203, 376-378

File class methods, 377-378

SD class methods, 376-377

Secure Digital. See SD cards

seek method, 377

Select All option (Edit menu), 45

semicolon (;), terminating statements, 77

sensitivity

of touch sensors, 300

of voltage-based analog sensors, 291-292

sensors, 18. See also analog sensors

Serial class functions, 83-84

serial communication protocols, 267-268

I2C (Inter-Integrated Circuit) protocol, 277-284

blinking LED example sketch, 280-284

interfaces, 278

Wire library functions, 278-280

serial ports, 268-274

blinking LED example sketch, 272-274

interfaces, 268-269

Serial library, 269-272

SPI (Serial Peripheral Interface) protocol, 274-277

functions, 276-277

interfaces, 274-276

serial events, 274

Serial library

functions, 269-272

interrupts in, 255

serial monitor, 52-54

with external power source, 69

viewing serial port output, 63

Serial Monitor icon (toolbar), 49

Serial Monitor option (Tools menu), 47

Serial Peripheral Interface (SPI) protocol, 274-277, 390

Ethernet shield, 338

functions, 276-277

interfaces, 274-276

Serial Port option (Tools menu), 47

serial ports, 268-274

blinking LED example sketch, 272-274

finding in Windows, 52

interfaces, 268-269

output

Serial class functions, 83-84

viewing, 63

Serial library, 269-272

serialEvent() function, 274

Server class. See EthernetServer class

server communication protocols, 345

Servo library, 203, 313-314

servo motors, 304

positioning example sketch, 314-316

Servo library, 313-314

setBacklightColor() function, 331

setBitOrder() function, 276-277

setCharAt method, 130

setClockDivider() function, 276-277

setCursor() function, 325

setDataMode() function, 276-277

setTimeout() function, 270

setup for Arduino IDE, 51-52

setup function, 58

shield libraries, 32. See also shields

including, 58-59

list of, 203-204

shields

defined, 18

Ethernet shield, 18-19, 337-338

chat server example sketch, 349-351

dynamic IP addresses, 342-343

Ethernet class, 340-341

Ethernet Shield library, 340

EthernetClient class, 343-345

EthernetServer class, 345-347

EthernetUDP class, 347-349

IPAddress class, 341-342

LCD shield, 19, 329-330

connections, 332-333

downloading and installing library, 330-331

library functions, 331-332

temperature display example sketch, 333-335

motor shield, 19, 316

Prototype shield, 20, 399-400

SD card support, 375-376

WiFi shield, 339

Show Sketch Folder option (Sketch menu), 46

signal duty cycle, 237

sin() function, 85

size method, 377

sizeof function, 111-112

sizing arrays, 111-112, 121-122

Sketch menu commands, 46

Sketchbook option (File menu), 41

sketches. See also Arduino programming language; listings

analog sensor interfaces

photoresistor example sketch, 296-297

temperature detection example sketch, 293-295

temperature LCD display example sketch, 327-329, 333-335

temperature logging example sketch, 382-384

temperature sensors for web servers, 361-364

touch sensor example sketch, 298-300

chat server example sketch, 349-351

coding format, 57-58

compiling, 60-61

DC motors

powering on/off, 308-311

speed control, 311-313

debugging, 83

editor window, 59-60

electronic circuit interfaces, 64-69

adding to projects, 68-69

analog output generation, 246-247

blinking LED example sketch, 272-274, 280-284

breadboards, 67-68

external interrupts, 255-260

header socket usage, 64-66

input mapping, 242-245

pin change interrupts, 261-262

potentiometer example sketch, 238-241

traffic signal example sketch, 223-226, 229-231, 364-370

example sketches, modifying, 41

file extensions, 41

formatting, 91

HTML in, 44

libraries, including, 58-59

planning, 394-395

restarting, 64, 92

running, 63-64

servo motors, positioning, 314-316

testing, 398-399

uploading, 62-63

writing, 395-398

slave mode (SPI), 274

sockets, 10-11

accessing, 66

electronic circuit interfaces, 64-66

on Uno R3 unit, 15-16

SoftwareSerial library, 203

speed of DC motors, controlling, 306-307, 311-313

SPI (Serial Peripheral Interface) protocol, 274-277, 390

Ethernet shield, 338

functions, 276-277

interfaces, 274-276

SPI library, 203, 276-277

sqrt() function, 85

SRAM memory, 25

comparison with EEPROM and flash memory, 181-182

dynamic variables, 185-189

changing, 187

defining, 186-187

example usage, 187-189

removing, 187

heap data area, 183-185

stack data area, 183-185

stack data area, 183-185

stack pointers, 24

standard libraries

compiling functions, 205

documentation, 205

example usage, 205-206

including, 204

list of, 203-204

referencing functions in, 204-205

startsWith method, 128

statements, terminating, 77

static IP addresses, 341-342

static random-access memory. See SRAM memory

status codes (HTTP), list of, 359

status line (HTTP responses), 358-360

status registers, 24

Stepper library, 203

stepper motors, 304

stop method

EthernetClient class, 343

EthernetUDP class, 347

storage. See also memory

SD cards

folder organization, 381-382

interfaces, 375-376

reading files, 379-380

SD library, 376-378

specifications, 373-375

temperature logging example sketch, 382-384

writing to files, 379

of strings, 78

of values with pointers, 167, 173-176

strcmp() function, 123, 125-126

strcmp_P() function, 191

strcpy() function, 123, 125, 137

strict typing, 76

String objects, 126-129

creating and manipulating, 126-128

in data structures, 142

methods

comparison, 128-129

manipulation, 130-131

strings

in Arduino programming language, 126-129

creating and manipulating, 126-128

manipulating, 130-131

String object methods, 128-129

in C programming language, 120-126

comparing, 125-126

creating, 121-122

functions for, 122-125

comparisons, 96

copying, 125

displaying, 122

explained, 119-120

manipulating with pointers, 171-172

referencing with pointers, 172-173

storing, 78

strlen() function, 123

strlen_P() function, 191

strstr() function, 123

struct statement, 134-136

structured commands. See also loops

comparisons, 95-97

Boolean comparisons, 96-97

compound conditions, 97

negating condition checks, 98

numeric comparisons, 95-96

string comparisons, 96

else if statements, 93-95

else statements, 92-93

if statements, 89-92

switch statements, 98-99

structures. See data structures

substring method, 128

subtraction operator, 80

switch bounce, 260, 332

switch statements, 98-99

switches, 17, 229-231

T

tan() function, 85

Telnet clients, 351

temperature detection example sketch, 293-295

for LCD displays, 327-329, 333-335

for SD cards, 382-384

for web servers, 361-364

temperature monitor example project

analog interfaces, 389-390

breadboard circuits, creating, 393-394

components needed, 391-392

digital interfaces, 390-391

planning, 388-389

schematics, creating, 392

sketches

planning, 394-395

testing, 398-399

writing, 395-398

terminating statements, 77

testing

function results, 97

I2C interface, 280-284

serial ports, 272-274

sketches, 398-399

timer interrupts, 263-264

text. See strings

text editor files, saving, 210

TFT library, 203

time functions, 84-85

timer interrupts, 254

importing Timer One library, 263

testing, 263-264

Timer One library, importing, 263

TMP36 sensor, 293-295, 361-364

toCharArray method, 128

toInt method, 128

toLowerCase method, 130

toolbar (Arduino IDE), 49

Tools menu commands, 46-48

touch sensors, 297-300

toUpperCase method, 130

TRACE method token, 357

trademark protection of Arduino name, 9

traffic signal example sketch

controlling from web browser, 364-370

external interrupts, 255-260

input mapping, 242-245

input mode, 229-231

output mode, 223-226

pin change interrupts, 261-262

transfer() function, 276-277

transistors, 305-306

Transistor-transistor-logic (TTL)-level voltages, 269

trcpy_P() function, 191

trim method, 130

troubleshooting

compiler errors, 61

debugging sketches, 83

digital interfaces

input voltage levels, 227

with serial monitor, 226

flushing SD card data, 378

functions, 148

importing PinChangeInt library, 261

LCD (liquid crystal display) devices, 329

memory

EEPROM memory, 194-195

out of memory errors, 186

missing libraries, 213

modifying example sketches, 41

switch bounce, 260

TTL (Transistor-transistor-logic)-level voltages, 269

TX -> 1 header socket port, 66

.txt file extension, 210

U

Ubuntu, Arduino IDE installation, 37

UDP (User Datagram Protocol), 347-349

Undo option (Edit menu), 44

unions, 142-145

Universal Resource Indicator (URI), 357

unnamed data structures, 136

Uno model, 12-13

analog interfaces, 236

digital interfaces, 219

external interrupts, 253

I2C interface pins, 278

specifications, 15-17

unsigned variable qualifier, 79

Upload icon (toolbar), 49

Upload option (File menu), 42

Upload Using Programmer option (File menu), 42

uploading

bootloader, 48

sketches, 62-63

URI (Universal Resource Indicator), 357

USB A-B cables, 17

USB hub, powering on/off Arduino, 69

USB ports on Uno R3 unit, 16

USB serial interface, 268

Use Selection for Find option (Edit menu), 46

User Datagram Protocol (UDP), 347-349

user-created libraries. See building libraries

user-defined functions, 147

calling, 148-150

defining, 148

passing values to, 152-154

recursive functions, 158-160

returning values, 150-152

scope of variables, 154

global variables, 155-156

local variables, 156-158

troubleshooting, 148

V

values

analog input values

limiting, 241

mapping, 242-245, 292

assigning

to data structures, 136-138

to variables, 77

passing to functions, 152-154

retrieving

from EEPROM memory, 196-197

from flash memory, 191-192

with pointers, 166-167, 173-176

returning

from functions, 150-152

in pointers, 178

storing with pointers, 167, 173-176

voltage values, converting, 292-293

variable resistors, 17

variables

arrays. See arrays

assigning values, 77

data structures. See data structures

data types, 77-78

declaring, 76-77

dynamic variables, 184-189

changing, 187

defining, 186-187

example usage, 187-189

removing, 187

in flash memory, 190-191

pointers. See pointers

qualifiers, 79

scope, 80

in functions, 154

global variables, 155-156

local variables, 156-158

unions, 142-145

viewing, 83

Verify icon (toolbar), 49

Verify/Compile option (Sketch menu), 46

viewing

serial port output, 63

variables, 83

Vin header socket port, 65

void data type, 148

void pointers, 168

voltage dividers, 289-290, 295-296

voltage levels

in analog sensors, 288-291

in capacitors, detecting, 297-298

for digital interfaces

in input mode, 226-229

in output mode, 221-223

reference voltages, changing, 245-246, 290-291

voltage-based analog sensors, 288-293

converting voltage values, 292-293

sensitivity of, 291-292

temperature detection example sketch, 293-295

voltage levels, 288-291

W

Wave shield, 376

web browsers, controlling Arduino from, 364-370

web servers, building, 361-364, 366-370

while statements, 104-106

Wifi library, 203

WiFi shield, 339

Windows

Arduino IDE installation, 33-36

serial ports, finding, 52

zip file creation, 211

Wire library, 203, 278-280

wires, 17

word data type, 77

write() function

EEPROM library, 194

LiquidCrystal library, 325

Serial library, 270-271

Servo library, 313

Wire library, 278

write method

EthernetClient class, 343

EthernetServer class, 345

EthernetUDP class, 347

File class, 377

write speeds (SD cards), 374

writeMicroseconds() function, 313

writing

to files on SD cards, 379

sketches, 395-398

Y

Yun model, 14-15

analog interfaces, 236

digital interfaces, 219

Z

zip files, creating, 211-212

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.145.179.35