Table of Contents

Copyright

Brief Table of Contents

Table of Contents

Preface

Acknowledgments

About this Book

About the Cover Illustration

1. Getting started

Chapter 1. Hello Arduino

1.1. A brief history of the Arduino

1.2. The Arduino hardware

1.2.1. Arduino Uno

1.2.2. Arduino Duemilanove

1.2.3. Arduino Ethernet

1.2.4. Arduino Mega

1.2.5. Other Arduino boards

1.2.6. Attack of the clones

1.2.7. Getting an Arduino

1.3. Setting up your working environment

1.3.1. Software for Arduino

1.3.2. Basic hardware setup

1.3.3. Your Arduino toolbox

1.4. Make something happen!

1.4.1. Your first blinking LED

1.4.2. Sketch to make an LED blink

1.4.3. Connecting everything

1.4.4. Uploading and testing

1.5. Touring the IDE

1.5.1. The main editor

1.5.2. Serial monitor

1.5.3. Catching errors

1.5.4. Process

1.6. Anatomy of a sketch

1.6.1. A routine called setup

1.6.2. The endless loop

1.7. Commenting code

1.8. Summary

Chapter 2. Digital input and output

2.1. Getting started

2.1.1. Using a breadboard

2.1.2. Circuit diagram

2.1.3. Adding the LEDs

2.1.4. Connecting the hardware

2.1.5. Sketch to flash five LEDs

2.1.6. Upload and test

2.2. Gaining control

2.2.1. Circuit diagram

2.2.2. Connections

2.2.3. Interrupts butting in

2.2.4. Sketch to control the LEDs with a push button

2.2.5. Upload and test

2.2.6. Time for a break

2.2.7. Upload and test

2.3. Reaction tester

2.3.1. Circuit diagram

2.3.2. Connections

2.3.3. Sketch to test reaction speed

2.3.4. Upload and test

2.4. Reactometer: Who really has the fastest reaction time?

2.4.1. Sketch to measure reaction speed

2.4.2. Upload and test

2.5. Summary

Chapter 3. Simple projects: input and output

3.1. Time to get analog

3.1.1. What’s the difference between analog and digital?

3.1.2. Reading a potentiometer

3.1.3. Connecting the hardware

3.1.4. Sketch to read a potentiometer

3.1.5. Upload and test

3.2. A piezoelectric transducer

3.2.1. The circuit diagram

3.2.2. Connecting the hardware

3.2.3. Sketch to measure output from a piezoelectric transducer

3.2.4. Upload and test

3.2.5. Circuit with added speaker

3.2.6. Connecting the hardware

3.2.7. Sketch to generate a tone

3.2.8. Upload and test

3.3. Making a pentatonic or five-tone keyboard

3.3.1. Circuit diagram

3.3.2. Connecting the hardware

3.3.3. Sketch to create a pentatonic keyboard

3.3.4. Upload and test

3.4. Summary

2. Putting Arduino to work

Chapter 4. Extending Arduino

4.1. Extending the Arduino with libraries

4.2. Core library

4.3. Standard libraries

4.3.1. Test-driven development with ArduinoTestSuite

4.3.2. Storing values using EEPROM

4.3.3. Storing more data with SD

4.3.4. Get connected with Ethernet

4.3.5. Serial communication with Firmata

4.3.6. Displaying data using the LiquidCrystal library

4.3.7. Controlling a servo motor

4.3.8. Turning a stepper motor

4.3.9. Communicating with SPI peripherals

4.3.10. Communicating with the two-wire interface

4.3.11. Get more serial ports with SoftwareSerial

4.4. Contributed libraries

4.4.1. Installing a new library

4.5. Expanding the Arduino with shields

4.5.1. Common shields

4.5.2. Gotchas: will it work with my Arduino?

4.6. Summary

Chapter 5. Arduino in motion

5.1. Getting up to speed with DC motors

5.1.1. Stopping and starting

5.1.2. Sketch to turn a small DC motor on and off

5.1.3. Connecting the hardware

5.1.4. Upload and test

5.2. Speed control and reverse

5.2.1. PWM to the rescue

5.2.2. The H-bridge for motor control

5.2.3. The L293D dual H driver

5.2.4. Connecting the hardware

5.2.5. Sketch to control a motor with an L293D

5.2.6. Upload and test

5.2.7. Changing motor speed

5.2.8. Upload and test

5.3. Stepper motors: one step at a time

5.3.1. Unipolar or bipolar

5.3.2. Connecting the hardware

5.3.3. Stepper motor library functions

5.3.4. Sketch to control a stepper motor

5.3.5. Upload and test

5.4. Try not to get in a flap with servomotors

5.4.1. Controlling a servomotor

5.4.2. Servomotor functions and methods

5.4.3. Sketch to control a servomotor

5.4.4. Connecting the hardware

5.4.5. Upload and test

5.5. Mighty power comes in small packages with brushless DC motors

5.5.1. Why go brushless

5.5.2. Gaining control

5.5.3. Sketch to control a brushless motor

5.5.4. Connecting the hardware

5.5.5. Upload and test

5.5.6. Reverse

5.5.7. Sketch to reverse a brushless motor

5.5.8. Connecting the hardware

5.5.9. Upload and test

5.6. The motor control shield for more motors

5.7. Summary

Chapter 6. Object detection

6.1. Object detection with ultrasound

6.1.1. Choosing an ultrasonic sensor

6.1.2. Three wires or four

6.1.3. Sketches for ultrasonic object finding

6.1.4. Connecting the hardware

6.1.5. Upload and test

6.2. Infrared for range finding

6.2.1. Infrared and ultrasound together

6.2.2. The Sharp GP2D12 range finder

6.2.3. Nonlinear algorithm for calculating distance

6.2.4. Sketch for range finding

6.2.5. Connecting the hardware

6.2.6. Upload and test

6.3. Passive infrared to detect movement

6.3.1. Using the Parallax PIR sensor

6.3.2. Sketch for infrared motion detection

6.3.3. Connecting the hardware

6.3.4. Upload and test

6.4. Summary

Chapter 7. LCD displays

7.1. Introduction to LCDs

7.1.1. String variables: String type vs. char type

7.2. Parallel character LCDs: the Hitachi HD44780

7.2.1. 4-bit or 8-bit?

7.2.2. Library and functions

7.2.3. Circuit diagram

7.2.4. Connecting everything up in 4-bit mode

7.2.5. Sketch for writing to the Hitachi HD44780

7.2.6. Upload and test

7.3. Serial LCD weather station

7.3.1. Serial vs. parallel LCDs

7.3.2. SerLCD library and functions

7.3.3. The Maxim IC DS18B20 temperature sensor

7.3.4. OneWire and DallasTemperature libraries

7.3.5. Circuit diagram

7.3.6. Connecting everything up

7.3.7. Sketch for an LCD weather station

7.3.8. Upload and test

7.4. Graphic LCDs: the Samsung KS0108 GLCD

7.4.1. Library and functions

7.4.2. Circuit diagram

7.4.3. Connecting everything up

7.4.4. Sketch for drawing to a GLCD

7.4.5. Upload and test

7.5. Summary

Chapter 8. Communications

8.1. Ethernet

8.1.1. The Ethernet library

8.1.2. Ethernet Shield with SD data card

8.2. Arduino web server

8.2.1. Setting up the server

8.2.2. Sketch for creating a web server

8.2.3. Upload and test

8.2.4. Troubleshooting

8.3. Tweet tweet: talking to Twitter

8.3.1. Of Twitter and tokens

8.3.2. Libraries and functions

8.3.3. Circuit diagram and connecting the hardware

8.3.4. Sketch for the Twitter button-press tweeter

8.3.5. Upload and test

8.4. Wi-Fi

8.4.1. Arduino Wifi Shield

8.4.2. WiFi library and functions

8.4.3. Gestures: wireless accelerometers

8.4.4. Connecting the hardware

8.4.5. Sketch for Bluetooth communication

8.4.6. Upload and test

8.5. Bluetooth wireless

8.5.1. ArduinoBT

8.5.2. Adding Bluetooth

8.5.3. Establishing a Bluetooth connection

8.5.4. Sketch for Bluetooth communication

8.6. Serial peripheral interface (SPI)

8.6.1. SPI library

8.6.2. SPI devices and digital potentiometers

8.6.3. Circuit diagram and connecting the hardware

8.6.4. Sketch for a digital LED dimmer

8.7. Data logging

8.7.1. Types of memory

8.7.2. SD cards and SD library

8.7.3. Sketch for an SD card sensor logger

8.8. Cosm

8.8.1. Sign up for an account and get an API key

8.8.2. Creating a new data feed

8.8.3. Sketch for Cosm sensor logging

8.8.4. Upload and test

8.9. Summary

Chapter 9. Game on

9.1. Nintendo Wii salutes you

9.1.1. Wii Nunchuk

9.1.2. Nunchuk connections

9.1.3. Wii will talk

9.1.4. Wii will test

9.2. Release the Xbox

9.2.1. Getting connected

9.2.2. USB Host library

9.2.3. Learning about the Xbox controller using the USB Host Shield

9.2.4. Xbox reporting for duty

9.2.5. Let’s boot it

9.2.6. Interfacing with code

9.2.7. Xboxhid.ino

9.2.8. Hardware connections and testing

9.3. Summary

Chapter 10. Integrating the Arduino with iOS

10.1. Connecting your device to the Arduino

10.1.1. The Redpark serial cable

10.1.2. The final connection

10.2. iOS code

10.2.1. Creating a single-view application in Xcode

10.2.2. Writing the code

10.3. The Arduino gets involved

10.3.1. Sketch to switch LED from iOS device

10.3.2. Testing the sketch

10.4. Doing more with Xcode

10.4.1. Adding a Slider control

10.5. Arduino sliding

10.5.1. Arduino slider circuit

10.5.2. Testing the circuit

10.6. Moving data to the iOS device

10.6.1. Xcode coding

10.6.2. The GP2D12 IR distance sensor

10.6.3. Testing

10.7. Summary

Chapter 11. Making wearables

11.1. Introducing the LilyPad

11.1.1. LilyPad accessories

11.1.2. Conductive thread and fabric

11.2. Creating a turn-signal jacket

11.3. Creating a wearable piano

11.4. The Arduino Pro Mini

11.5. Creating a smart headphone

11.6. Creating a jacket with a compass

11.7. Summary

Chapter 12. Adding shields

12.1. Shield basics

12.2. The Adafruit motor shield

12.2.1. The AFMotor library

12.2.2. Using the motor shield with a stepper motor

12.2.3. Using the motor shield with a DC motor

12.2.4. Getting a motor shield

12.3. Creating your own shield

12.3.1. Memory

12.3.2. Level shifters

12.3.3. The SD card holder

12.3.4. Connecting the SD card to the Arduino

12.3.5. Preparing the perfboard

12.3.6. Testing the shield

12.4. Summary

Chapter 13. Software integration

13.1. The serial channel

13.2. Servos for face tracking

Serial communication in Processing

13.2.2. Code for face-tracking

13.3. Using Firmata to create an equalizer

13.3.1. Using Firmata in your application

13.3.2. Audio analysis in Processing

13.3.3. Assembling the equalizer hardware

13.3.4. Code for the equalizer

13.4. Using Pure Data to create a synthesizer

13.4.1. Assembling the synthesizer hardware

13.4.2. Code for the synthesizer

13.5. Using Python to monitor temperatures

13.5.1. The Serial library in Python

13.5.2. Assembling the thermometer hardware

13.5.3. Code for monitoring temperatures

13.6. Summary

Appendix A. Installing the Arduino IDE

A.1. Windows

A.1.1. Installing drivers for your board

A.2. Mac OS X

A.3. Linux

Appendix B. Coding primer

B.1. The Arduino language

B.2. Variables

B.2.1 Variable types

B.2.2 Arrays

B.2.3 Strings

B.2.4 Constants

B.2.5 Variable scope

B.3. Taking control

B.3.1 If, else, else if

B.3.2 Switch case

B.3.3 Logical operators

B.4. Going loopy

B.4.1. The for loop

B.4.2. The while loop

B.4.3. The do while loop

B.5. Functions

B.6. Summary

Appendix C. Libraries

C.1. Anatomy of a library

C.1.1. The .h (header) file

C.1.2. The .cpp file

C.2. Using a library

C.2.1. Using a library in a sketch

C.2.2. Distributing a library

Appendix D. Components list

Chapter 1

Chapter 2

Chapter 3

Chapter 4

Chapter 5

Chapter 6

Chapter 7

Chapter 8

Chapter 9

Chapter 10

Chapter 11

Chapter 12

Chapter 13

Appendix E. Useful links

Additional Arduino articles

Other useful links and materials

Index

List of Figures

List of Tables

List of Listings

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

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