Programming Arduino Next Steps: Going Further with Sketches, Second Edition

Programming Arduino Next Steps: Going Further with Sketches, Second Edition

by Simon Monk

NOOK Book(eBook)

$12.49 $20.00 Save 38% Current price is $12.49, Original price is $20. You Save 38%.
View All Available Formats & Editions

Available on Compatible NOOK Devices and the free NOOK Apps.
WANT A NOOK?  Explore Now

Overview

Go beyond the basics with this up to date Arduino programming resource
Take your Arduino programming skills to the next level using the hands-on information contained in this thoroughly revised, easy to follow TAB guide. Aimed at programmers and hobbyists who have mastered the fundamentals, Programming Arduino Next Steps: Going Further with Sketches, Second Edition reveals professional programming tips and tricks. This up-to-date edition covers the Internet of Things (IoT) and features new chapters on interfacing your Arduino with other microcontrollers. You will get dozens of illustrated examples and downloadable code examples that clearly demonstrate each powerful technique.
Discover how to:
•Configure your Arduino IDE and develop your own sketches•Boost performance and speed by writing time-efficient sketches •Optimize power consumption and memory usage •Interface with different types of serial busses, including I2C, 1-Wire, SPI, and TTL Serial •Use Arduino with USB and UART •Incorporate Ethernet, Bluetooth, and DSP•Program Arduino for the Internet •Manage your sketches using One Process•Accomplish more than one task at a time―without multi-threading •Create your own code library and share it with other hobbyists

Product Details

ISBN-13: 9781260143256
Publisher: McGraw-Hill Education
Publication date: 11/02/2018
Sold by: Barnes & Noble
Format: NOOK Book
Sales rank: 1,111,744
File size: 18 MB
Note: This product may take a few minutes to download.

About the Author

Dr. Simon Monk has a bachelor’s degree in cybernetics and computer science and a Ph.D. in software engineering. He has authored more than 20 books, including Programming Arduino: Getting Started with Sketches, Programming Arduino, 30 Arduino Projects for the Evil Genius, and Fritzing for Inventors. Dr. Monk also runs the website monk.makes.com, which features his own products.

Table of Contents

Acknowledgments xvii

Introduction xix

1 Programming Arduino 1

What Is Arduino? 1

Installation and the IDE 4

Installing the IDE 4

Blink 4

A Tour of Arduino 7

Power Supply 8

Power Connections 8

Analog Inputs 9

Digital Connections 9

Arduino Boards 10

Uno and Similar 10

Big Arduino Boards 11

Small Arduino Boards 13

LilyPad and LilyPad USB Boards 13

Unofficial Arduinos 13

Programming Language 15

Modifying the Blink Sketch 15

Variables 17

If 18

Loops 19

Functions 20

Digital Inputs 22

Digital Outputs 24

The Serial Monitor 24

Arrays and Strings 26

Analog Inputs 28

Analog Outputs 30

Using Libraries 32

Arduino Data Types 34

Arduino Commands 35

Summary 36

2 Under the Hood 37

A Brief History of Arduino 37

Anatomy of an Arduino 38

AVR Processors 39

ATmega328 39

ATmega32u4 41

ATmega2560 41

AT91SAM3X8E 41

Arduino and Wiring 42

From Sketch to Arduino 46

AVR Studio 49

Installing a Bootloader 51

Burning a Bootloader with AVR Studio and a Programmer 51

Burning a Bootloader with the Arduino IDE and a Second Arduino 53

Summary 55

3 Interrupts and Timers 57

Hardware Interrupts 57

Interrupt Pins 60

Interrupt Modes 61

Enabling Internal Pull-Up 61

Interrupt Service Routines 62

Volatile Variables 63

ISR Summary 64

Enabling and Disabling Interrupts 64

Timer Interrupts 64

Summary 68

4 Making Arduino Faster 69

How Fast Is an Arduino? 69

Comparing Arduino Boards 70

Speeding Up Arithmetic 71

Do You Really Need to Use a Float? 72

Lookup vs. Calculate 72

Fast I/O 75

Basic Code Optimization 75

Bytes and Bits 77

ATmega328 Ports 77

Very Fast Digital Output 79

Fast Digital Input 80

Speeding Up Analog Inputs 81

Summary 83

5 Low Power Arduino 85

Power Consumption of Arduino Boards 85

Current and Batteries 87

Reducing the Clock Speed 88

Turning Things Off 90

Sleeping 92

Narcoleptic 92

Waking on External Interrupts 94

Use Digital Outputs to Control Power 97

Summary 99

6 Memory 101

Arduino Memory 101

Minimizing RAM Usage 103

Use the Right Data Structures 103

Be Careful with Recursion 104

Store String Constants in Hash Memory 106

Common Misconceptions 106

Measure Free Memory 107

Minimizing Flash Usage 108

Use Constants 108

Remove Unwanted Trace 108

Bypass the Bootloader 109

Static vs. Dynamic Memory Allocation 109

Strings 111

C char Arrays 111

The Arduino String Object Library 114

Using EEPROM 115

EEPROM Example 116

Using the avr/eeprom.h Library 119

EEPROM Limitations 121

Using Flash 121

Using SD Card Storage 123

Summary 124

7 Using 12C 125

12C Hardware 127

The 12C Protocol 128

The Wire Library 129

Initializing 12C 129

Master Sending Data 129

Master Receiving Data 130

12C Examples 131

TEA5767 FM Radio 131

Arduino-to-Arduino Communication 133

LED Backpack Boards 136

DS1307 Real-Time Clock 137

Summary 139

8 Interfacing with 1-Wire Devices 141

1-Wire Hardware 141

The 1-Wire Protocol 142

The OneWire Library 142

Initializing 1-Wire 143

Scanning the Bus 143

Using the DS18B20 145

Summary 147

9 Interfacing with SPI Devices 149

Bit Manipulation 149

Binary and Hex 150

Masking Bits 151

Shifting Bits 152

SPI Hardware 154

The SPI Protocol 156

The SPI Library 156

SPI Example 158

Summary 162

10 Serial UART Programming 163

Serial Hardware 163

Serial Protocol 165

The Serial Commands 166

The SoftwareSerial Library 168

Serial Examples 169

Computer to Arduino over USB 169

Arduino to Arduino 171

GPS Module 174

Summary 178

11 USB Programming 179

Keyboard and Mouse Emulation 179

Keyboard Emulation 180

Keyboard Emulation Example 181

Mouse Emulation 182

Mouse Emulation Example 182

USB Host Programming 183

USB Host Shield and Library 183

USB Host on the Arduino Due 188

Summary 191

12 Network Programming 193

Networking Hardware 193

Ethernet Shield 193

Arduino Ethernet/EtherTen 194

Arduino and WiFi 194

The Ethernet Library 196

Making a Connection 196

Setting Up a Web Server 199

Making Requests 200

Ethernet Examples 201

Physical Web Server 201

Using a JSON Web Service 206

The WiFi Library 208

Making a Connection 208

WiFi Specific Functions 208

WiFi Example 209

Summary 210

13 Digital Signal Processing 211

Introducing Digital Signal Processing 211

Averaging Readings 213

An Introduction to Filtering 215

Creating a Simple Low-Pass Filter 215

Arduino UnoDSP 217

Arduino DueDSP 219

Filter Code Generation 221

The Fourier Transform 224

Spectrum Analyzer Example 226

Frequency Measurement Example 228

Summary 229

14 Managing with One Process 231

Making the Transition from Big Programming 231

Why You Don't Need Threads 232

Setup and Loop 232

Sense Then Act 233

Pause Without Blocking 234

The Timer Library 235

Summary 237

15 Writing Libraries 239

When to Make a Library 239

Using Classes and Methods 240

Library Example (TEA5767 Radio) 240

Define the API 241

Write the Header File 243

Write the Implementation File 243

Write the Keywords File 244

Make the Examples Folder 245

Testing the Library 246

Releasing the Library 246

Summary 247

A Parts 249

Arduino Boards 249

Shields 249

Components and Modules 250

Suppliers 250

Index 251

Customer Reviews

Most Helpful Customer Reviews

See All Customer Reviews