Practical Arduino engineering

4 downloads 146 Views 257KB Size Report
Contents. J. About the Author .. xiii. About the Technical Reviewer. - xvi. Acknowledgments xv. Preface xvi. Chapter 1: The Process of Arduino Engineering. 1.
Practical Arduino

Engineering

Timmis

Contents

J About the Author

..

About the Technical Reviewer

-

Acknowledgments

xiii xvi xv

Preface

xvi

Chapter 1: The Process of Arduino Engineering

1

Gathering Your Hardware

1

Gathering Your Tools

8

Understanding

the

Engineering

Process

9

Requirements Gathering

9

Creating the Requirements Document

9

Gathering the Hardware

10

Configuring the Hardware

10

Writing the Software

12

Debugging the Arduino Software

13

Troubleshooting the Hardware

14

Finished Prototype

14

Summary

14

Chapter 2: Understanding the Arduino Software..............

15

Getting Started with setupO and loopO

15

Variables

16

Writing Conditional Statements

18

Initializing

CONTENTS

Working

with

19

Loops

Communicating Digitally

20

Communicating

21

with

Analog Components

Serial Communication

21

Using Arduino Libraries

23

NewSoftwareSerial

24

TinyGPS

24

ColorLCDShield Library

24

Putting Together the Arduino Language

Basics

25

Summary

26

Chapter 3: Robot Engineering Requirements: Controlling Motion ........................27 Hardware Explained: The H-bridge

27

Gathering the Hardware for this Chapter

28

Understanding the Basics of Motor

Control

29

Project 3-1: Turning

Motor with

a

Switch

29

Project 3-2: Controlling the Speed of

a

Motor with a Potentiometer

34

on a

Project 3-3: Controlling Multiple Motors with the Arduino

38

Project 3-4: Controlling Speed and Direction

,

Project 3-5: Controlling Motors with Serial Commands

43 47

Summary

60

Chapter 4: Adding Complexity to the Robot: Working with LCDs

61

Color LCD Shield

Configuring

a

Introducing

the Monochrome and Color LCD Shields

Working with the LiquidCrystal and ColorLCDShield (Epson

61

62 or

Phillips) Libraries

64

Using the LiquidCrystal Library

64

ColorLCDShield

66

Library

CONTENTS

Exploring the

67

Basics of LCD Control

Project 4-1: Displaying Multiple Sensor Values

67

Project 4-2: Creating

a Menu on the Monochrome LCD

71

Project 4-3: Creating

a

Project 4-4: Using

a

Slot Machine with the Color LCD Shield

76

Keypad to Communicate with the Color LCD

81

Project 4-5: Creating the

84

Customer's Robot

Summary

96

Chapter 5: Robot Integration Engineering a GPS Module with the Arduino

97

Hardware

97

Explained: microSD Shield

Understanding NMEA Protocol

98

Libraries

99

Explained: TinyGPS and SdFat Libraries

99

TinyGPS SdFat

100

Library

The Basics of GPS Communication with the Arduino

101

Project 5-1: Writing Raw GPS Data to the Serial Monitor

101

Project 5-2: Writing GPS Data to

104

Project 5-3: Creating

a

a Monochrome LCD

108

Car Finder

Project 5-4: GPS Data Logger

Requirements Gathering

and

114

Creating the Requirements

Document

119

Hardware

119

Software

120

131

Summary Chapter

6: Interlude: Home

Engineering from Requirements to lmplementation133

Understanding the Voltage Divider Hardware

Explained: Sensors

133 134

Photoresistor

135

Tilt Sensor

135

vii

CONTENTS

Flex Sensor

136

Force Sensitive Resistor

136

(FSR)

Digital Temperature and Humidity Sensor

137

Digital Temperature Sensor (I2C)

137

Libraries Wire

Explained: Wire Library and DHT22 Library

Library

DHT22

138 138

Library

Understanding the Basics of Sensors

139

Project 6-1: Flower Pot Analyzer

139

Sensor

144

a Flex Sensor

147

Project

6-2:

Using

Project 6-3: Using

a FSR

Project 6-4: Digital Level Project 6-5: Using

a

DHT22 Sensor with

149 a

Monochrome LCD

152

Project 6-6: Wireless Temperature Monitor

156

Requirements Gathering and Creating the Requirements Document

156

Writing the Software

162

Troubleshooting the Hardware

163

Final

163

Prototype

164

Summary

Chapter

7: Robot

Hardware

Perception: Object Detection

with the Arduino

Explained: Ultrasonic Sensor, Servo, and Buzzer

165 165

Ultrasonic Sensor

165

Servo

167

Buzzer

167

Libraries Explained: The Servo Library

168

Basics of the Ultrasonic Sensor and the Servo

169

Project 7-1-.Digital Ruler

viii

138

169

CONTENTS

Project 7-2: Object Alarm

172

Project 7-3: Solar Controller

175

Requirements Gathering and Creating the Requirements Document

180

Hardware

180

Software

181

Summary

195

Chapter 8: Mature Arduino Engineering: Making an Alarm System Using the 197

Arduino

Security System

198

Project 8-1: Door Alarm

198

Basic

Requirements Gathering and Creating the Requirements Document B

Chapter

9: Error

207

Messages and Commands: Using GSM Technology with Your 217

Arduino Hardware Explained: Cellular Shield

217

Understanding the AT Command Set

218

The Basics of GSM Communication

219

Project 9-1: Sending a Text Message

219

Project 9-2: Door Alarm with SMS Messaging

225

Requirements Gathering and Creating the Requirements Document

230

Summary

237

Chapter 10: Control and Instrumentation: The Xbox Controller and the LabVIEW 239

Process Introduction to the LabVIEW Environment

239

The Front Panel

240

The Controls Palette

241

The Block

241

Diagram

The Functions Palette

242

ix

CONTENTS

The Tools Palette

243

LabVIEW Functions Explained The While

244 244

Loop

The Case Structure

245

The Sequence Structure

245

Numerical Functions

246

String Functions

247

Comparison Functions

249

Serial Functions

250

Input Device Control Functions

252

Gathering Requirements

and

Creating the Requirements Document

Getting Started

256

Designing the GUI

258

Programming the Application

259

Adding Serial Functions

262

Completing the While Loops Condition

265

Merge Errors Function

Adding

a

Adding

a SubVI

Error

Handling

265 266 267

Uploading the Code to the Arduino

269

Operation

273

Summary Chapter

276

11:

Controlling Your Project: Bluetooth Arduino

Gathering Requirements and Creating the Requirements Document Configuring the Hardware

277 277 ....280

Soldering the Headers

282

Pins and

283

Beyond

Configuring the Chassis and Arduino x

253

287

CONTENTS

Writing the Software

288

Reviewing the LabVIEW Software

288

Reviewing the Arduino Software

291

Uploading

the Software and

Attaching the Bluetooth Shield

293

Operating the Robot

293

Summary

297

Appendix A: Hardware and Tools

299