Book description
Create your own toys, remote controllers, alarms, detectors, robots, and many other projects with the Arduino device. This simple microcontroller board lets artists and designers build a variety of amazing objects and prototypes that interact with the physical world. With this cookbook you can dive right in and experiment with more than a hundred tips and techniques, no matter what your skill level is.
The recipes in this book provide solutions for most common problems and questions Arduino users have, including everything from programming fundamentals to working with sensors, motors, lights, and sound, or communicating over wired and wireless networks. You'll find the examples and advice you need to begin, expand, and enhance your projects right away.
- Get to know the Arduino development environment
- Understand the core elements of the Arduino programming language
- Use common output devices for light, motion, and sound
- Interact with almost any device that has a remote control
- Learn techniques for handling time delays and time measurement
- Use simple ways to transfer digital information from sensors to the Arduino device
- Create complex projects that incorporate shields and external modules
- Use and modify existing Arduino libraries, and learn how to create your own
Publisher resources
Table of contents
- A Note Regarding Supplemental Files
- Preface
- 1. Getting Started
-
2. Making the Sketch Do Your Bidding
- 2.0. Introduction
- 2.1. Structuring an Arduino Program
- 2.2. Using Simple Primitive Types (Variables)
- 2.3. Using Floating-Point Numbers
- 2.4. Working with Groups of Values
- 2.5. Using Arduino String Functionality
- 2.6. Using C Character Strings
- 2.7. Splitting Comma-Separated Text into Groups
- 2.8. Converting a Number to a String
- 2.9. Converting a String to a Number
- 2.10. Structuring Your Code into Functional Blocks
- 2.11. Returning More Than One Value from a Function
- 2.12. Taking Actions Based on Conditions
- 2.13. Repeating a Sequence of Statements
- 2.14. Repeating Statements with a Counter
- 2.15. Breaking Out of Loops
- 2.16. Taking a Variety of Actions Based on a Single Variable
- 2.17. Comparing Character and Numeric Values
- 2.18. Comparing Strings
- 2.19. Performing Logical Comparisons
- 2.20. Performing Bitwise Operations
- 2.21. Combining Operations and Assignment
-
3. Using Mathematical Operators
- 3.0. Introduction
- 3.1. Adding, Subtracting, Multiplying, and Dividing
- 3.2. Incrementing and Decrementing Values
- 3.3. Finding the Remainder After Dividing Two Values
- 3.4. Determining the Absolute Value
- 3.5. Constraining a Number to a Range of Values
- 3.6. Finding the Minimum or Maximum of Some Values
- 3.7. Raising a Number to a Power
- 3.8. Taking the Square Root
- 3.9. Rounding Floating-Point Numbers Up and Down
- 3.10. Using Trigonometric Functions
- 3.11. Generating Random Numbers
- 3.12. Setting and Reading Bits
- 3.13. Shifting Bits
- 3.14. Extracting High and Low Bytes in an int or long
- 3.15. Forming an int or long from High and Low Bytes
-
4. Serial Communications
- 4.0. Introduction
- 4.1. Sending Debug Information from Arduino to Your Computer
- 4.2. Sending Formatted Text and Numeric Data from Arduino
- 4.3. Receiving Serial Data in Arduino
- 4.4. Sending Multiple Text Fields from Arduino in a Single Message
- 4.5. Receiving Multiple Text Fields in a Single Message in Arduino
- 4.6. Sending Binary Data from Arduino
- 4.7. Receiving Binary Data from Arduino on a Computer
- 4.8. Sending Binary Values from Processing to Arduino
- 4.9. Sending the Value of Multiple Arduino Pins
- 4.10. How to Move the Mouse Cursor on a PC or Mac
- 4.11. Controlling Google Earth Using Arduino
- 4.12. Logging Arduino Data to a File on Your Computer
- 4.13. Sending Data to Two Serial Devices at the Same Time
- 4.14. Receiving Serial Data from Two Devices at the Same Time
- 4.15. Setting Up Processing on Your Computer to Send and Receive Serial Data
-
5. Simple Digital and Analog Input
- 5.0. Introduction
- 5.1. Using a Switch
- 5.2. Using a Switch Without External Resistors
- 5.3. Reliably Detecting the Closing of a Switch
- 5.4. Determining How Long a Switch Is Pressed
- 5.5. Reading a Keypad
- 5.6. Reading Analog Values
- 5.7. Changing the Range of Values
- 5.8. Reading More Than Six Analog Inputs
- 5.9. Displaying Voltages Up to 5V
- 5.10. Responding to Changes in Voltage
- 5.11. Measuring Voltages More Than 5V (Voltage Dividers)
-
6. Getting Input from Sensors
- 6.0. Introduction
- 6.1. Detecting Movement
- 6.2. Detecting Light
- 6.3. Detecting Motion (Integrating Passive Infrared Detectors)
- 6.4. Measuring Distance
- 6.5. Measuring Distance Accurately
- 6.6. Detecting Vibration
- 6.7. Detecting Sound
- 6.8. Measuring Temperature
- 6.9. Reading RFID Tags
- 6.10. Tracking the Movement of a Dial
- 6.11. Tracking the Movement of More Than One Rotary Encoder
- 6.12. Tracking the Movement of a Dial in a Busy Sketch
- 6.13. Using a Mouse
- 6.14. Getting Location from a GPS
- 6.15. Detecting Rotation Using a Gyroscope
- 6.16. Detecting Direction
- 6.17. Getting Input from a Game Control Pad (PlayStation)
- 6.18. Reading Acceleration
-
7. Visual Output
- 7.0. Introduction
- 7.1. Connecting and Using LEDs
- 7.2. Adjusting the Brightness of an LED
- 7.3. Driving High-Power LEDs
- 7.4. Adjusting the Color of an LED
- 7.5. Sequencing Multiple LEDs: Creating a Bar Graph
- 7.6. Sequencing Multiple LEDs: Making a Chase Sequence (Knight Rider)
- 7.7. Controlling an LED Matrix Using Multiplexing
- 7.8. Displaying Images on an LED Matrix
- 7.9. Controlling a Matrix of LEDs: Charlieplexing
- 7.10. Driving a 7-Segment LED Display
- 7.11. Driving Multidigit, 7-Segment LED Displays: Multiplexing
- 7.12. Driving Multidigit, 7-Segment LED Displays Using MAX7221 Shift Registers
- 7.13. Controlling an Array of LEDs by Using MAX72xx Shift Registers
- 7.14. Increasing the Number of Analog Outputs Using PWM Extender Chips (TLC5940)
- 7.15. Using an Analog Panel Meter As a Display
-
8. Physical Output
- 8.0. Introduction
- 8.1. Controlling the Position of a Servo
- 8.2. Controlling One or Two Servos with a Potentiometer or Sensor
- 8.3. Controlling the Speed of Continuous Rotation Servos
- 8.4. Controlling Servos from the Serial Port
- 8.5. Driving a Brushless Motor (Using a Hobby Speed Controller)
- 8.6. Controlling Solenoids and Relays
- 8.7. Making an Object Vibrate
- 8.8. Driving a Brushed Motor Using a Transistor
- 8.9. Controlling the Direction of a Brushed Motor with an H-Bridge
- 8.10. Controlling the Direction and Speed of a Brushed Motor with an H-Bridge
- 8.11. Using Sensors to Control the Direction and Speed of Brushed Motors (L293 H-Bridge)
- 8.12. Driving a Bipolar Stepper Motor
- 8.13. Driving a Bipolar Stepper Motor (Using the EasyDriver Board)
- 8.14. Driving a Unipolar Stepper Motor (ULN2003A)
- 9. Audio Output
- 10. Remotely Controlling External Devices
-
11. Using Displays
- 11.0. Introduction
- 11.1. Connecting and Using a Text LCD Display
- 11.2. Formatting Text
- 11.3. Turning the Cursor and Display On or Off
- 11.4. Scrolling Text
- 11.5. Displaying Special Symbols
- 11.6. Creating Custom Characters
- 11.7. Displaying Symbols Larger Than a Single Character
- 11.8. Displaying Pixels Smaller Than a Single Character
- 11.9. Connecting and Using a Graphical LCD Display
- 11.10. Creating Bitmaps for Use with a Graphical Display
- 11.11. Displaying Text on a TV
- 12. Using Time and Dates
-
13. Communicating Using I2C and SPI
- 13.0. Introduction
- 13.1. Controlling an RGB LED Using the BlinkM Module
- 13.2. Using the Wii Nunchuck Accelerometer
- 13.3. Interfacing to an External Real-Time Clock
- 13.4. Adding External EEPROM Memory
- 13.5. Reading Temperature with a Digital Thermometer
- 13.6. Driving Four 7-Segment LEDs Using Only Two Wires
- 13.7. Integrating an I2C Port Expander
- 13.8. Driving Multidigit, 7-Segment Displays Using SPI
- 13.9. Communicating Between Two or More Arduino Boards
- 14. Wireless Communication
-
15. Ethernet and Networking
- 15.0. Introduction
- 15.1. Setting Up the Ethernet Shield
- 15.2. Obtaining Your IP Address Automatically
- 15.3. Resolving Hostnames to IP Addresses (DNS)
- 15.4. Requesting Data from a Web Server
- 15.5. Requesting Data from a Web Server Using XML
- 15.6. Setting Up an Arduino to Be a Web Server
- 15.7. Handling Incoming Web Requests
- 15.8. Handling Incoming Requests for Specific Pages
- 15.9. Using HTML to Format Web Server Responses
- 15.10. Serving Web Pages Using Forms (POST)
- 15.11. Serving Web Pages Containing Large Amounts of Data
- 15.12. Sending Twitter Messages
- 15.13. Sending and Receiving Simple Messages (UDP)
- 15.14. Getting the Time from an Internet Time Server
- 15.15. Monitoring Pachube Feeds
- 15.16. Sending Information to Pachube
- 16. Using, Modifying, and Creating Libraries
-
17. Advanced Coding and Memory
Handling
- 17.0. Introduction
- 17.1. Understanding the Arduino Build Process
- 17.2. Determining the Amount of Free and Used RAM
- 17.3. Storing and Retrieving Numeric Values in Program Memory
- 17.4. Storing and Retrieving Strings in Program Memory
- 17.5. Using #define and const Instead of Integers
- 17.6. Using Conditional Compilations
-
18. Using the Controller Chip Hardware
- 18.0. Introduction
- 18.1. Storing Data in Permanent EEPROM Memory
- 18.2. Using Hardware Interrupts
- 18.3. Setting Timer Duration
- 18.4. Setting Timer Pulse Width and Duration
- 18.5. Creating a Pulse Generator
- 18.6. Changing a Timer’s PWM Frequency
- 18.7. Counting Pulses
- 18.8. Measuring Pulses More Accurately
- 18.9. Measuring Analog Values Quickly
- 18.10. Reducing Battery Drain
- 18.11. Setting Digital Pins Quickly
- A. Electronic Components
- B. Using Schematic Diagrams and Data Sheets
- C. Building and Connecting the Circuit
- D. Tips on Troubleshooting Software Problems
- E. Tips on Troubleshooting Hardware Problems
- F. Digital and Analog Pins
- G. ASCII and Extended Character Sets
- Index
- About the Author
- Colophon
- Copyright
Product information
- Title: Arduino Cookbook
- Author(s):
- Release date: March 2011
- Publisher(s): O'Reilly Media, Inc.
- ISBN: 9780596802479
You might also like
book
Arduino Cookbook, 2nd Edition
Want to create devices that interact with the physical world? This cookbook is perfect for anyone …
book
Arduino Cookbook, 3rd Edition
Want to create devices that interact with the physical world? This cookbook is perfect for anyone …
book
Mastering Arduino
Mastering Arduino is a practical, no-nonsense guide that will teach you the electronics and programming skills …
book
Arduino Development Cookbook
Over 50 hands-on recipes to quickly build and understand Arduino projects, from the simplest to the …