You are previewing Arduino Microcontroller Processing for Everyone!.
O'Reilly logo
Arduino Microcontroller Processing for Everyone!

Book Description

This book is about the Arduino microcontroller and the Arduino concept. The visionary Arduino team of Massimo Banzi, David Cuartielles, Tom Igoe, Gianluca Martino, and David Mellis launched a new innovation in microcontroller hardware in 2005, the concept of open source hardware. Their approach was to openly share details of microcontroller-based hardware design platforms to stimulate the sharing of ideas and promote innovation. This concept has been popular in the software world for many years. This book is intended for a wide variety of audiences including students of the fine arts, middle and senior high school students, engineering design students, and practicing scientists and engineers. To meet this wide audience, the book has been divided into sections to satisfy the need of each reader. The book contains many software and hardware examples to assist the reader in developing a wide variety of systems. The book covers two different Arduino products: the Arduino UNO R3 equipped with the Atmel ATmega328 and the Arduino Mega 2560 equipped with the Atmel ATmega2560. The third edition has been updated with the latest on these two processing boards, changes to the Arduino Development Environment and multiple extended examples.

Table of Contents

  1. Cover
  2. Half title
  3. Synthesis Lectures on Digital Circuits and Systems
  4. Copyright
  5. Title
  6. Abstract
  7. Contents
  8. Preface
  9. 1 Getting Started
    1. 1.1 Overview
    2. 1.2 Getting Started
    3. 1.3 Arduino UNO R3 processing board
      1. 1.3.1 Arduino UNO R3 host processor–the ATmega328
      2. 1.3.2 Arduino UNO R3/ATmega328 hardware features
      3. 1.3.3 ATmega328 Memory
      4. 1.3.4 ATmega328 Port System
      5. 1.3.5 ATmega328 Internal Systems
      6. 1.3.6 Arduino UNO R3 open source schematic
    4. 1.4 Arduino Mega 2560 processing board
      1. 1.4.1 Arduino Mega 2560 host processor–the ATmega2560
      2. 1.4.2 Arduino Mega 2560 /ATmega2560 hardware features
      3. 1.4.3 ATmega2560 Memory
      4. 1.4.4 ATmega2560 Port System
      5. 1.4.5 ATmega2560 Internal Systems
    5. 1.5 Arduino Mega 2560 open source schematic
    6. 1.6 Example: Autonomous Maze Navigating Robot
      1. 1.6.1 Structure chart
      2. 1.6.2 UML activity diagrams
      3. 1.6.3 Arduino UNO R3 Systems
    7. 1.7 Other Arduino–based platforms
    8. 1.8 Extending the hardware features of the Arduino platforms
    9. 1.9 Application: Arduino Hardware Studio
    10. 1.10 Summary
    11. 1.11 References
    12. 1.12 Chapter Problems
  10. 2 Programming
    1. 2.1 Overview
    2. 2.2 The Big Picture
    3. 2.3 Arduino Development Environment
      1. 2.3.1 Background
      2. 2.3.2 Quick start Guide
      3. 2.3.3 Arduino Development Environment overview
      4. 2.3.4 Sketchbook concept
      5. 2.3.5 Arduino software, libraries, and language references
      6. 2.3.6 Writing an Arduino Sketch
    4. 2.4 Anatomy of a Program
      1. 2.4.1 Comments
      2. 2.4.2 Include files
      3. 2.4.3 Functions
      4. 2.4.4 Program constants
      5. 2.4.5 Interrupt handler definitions
      6. 2.4.6 Variables
      7. 2.4.7 Main program
    5. 2.5 Fundamental programming concepts
      1. 2.5.1 Operators
      2. 2.5.2 Programming constructs
      3. 2.5.3 Decision processing
    6. 2.6 Application 1: Robot IR sensor
    7. 2.7 Application 2: Art piece illumination system
    8. 2.8 Application 3: Friend or Foe Signal
    9. 2.9 Summary
    10. 2.10 References
    11. 2.11 Chapter Problems
  11. 3 Embedded Systems Design
    1. 3.1 What is an embedded system?
    2. 3.2 Embedded system design process
      1. 3.2.1 Project Description
      2. 3.2.2 Background Research
      3. 3.2.3 Pre–Design
      4. 3.2.4 Design
      5. 3.2.5 Implement Prototype
      6. 3.2.6 Preliminary Testing
      7. 3.2.7 Complete and Accurate Documentation
    3. 3.3 Example: Blinky 602A autonomous maze navigating robot system design
    4. 3.4 Application: Control algorithm for the Blinky 602A Robot
    5. 3.5 Summary
    6. 3.6 References
    7. 3.7 Chapter Problems
  12. 4 Atmel AVR Operating Parameters and Interfacing
    1. 4.1 Overview
    2. 4.2 Operating Parameters
    3. 4.3 Battery Operation
      1. 4.3.1 Embedded system voltage and current drain specifications
      2. 4.3.2 Battery characteristics
    4. 4.4 Input Devices
      1. 4.4.1 Switches
      2. 4.4.2 Pullup resistors in switch interface circuitry
      3. 4.4.3 Switch Debouncing
      4. 4.4.4 Keypads
      5. 4.4.5 Sensors
    5. 4.5 Output Devices
      1. 4.5.1 Light Emitting Diodes (LEDs)
      2. 4.5.2 Seven Segment LED Displays
      3. 4.5.3 Code Example
      4. 4.5.4 Tri–state LED Indicator
      5. 4.5.5 Dot Matrix Display
      6. 4.5.6 Liquid Crystal Character Display (LCD) in C
      7. 4.5.7 Programming a serial configured LCD
      8. 4.5.8 Liquid Crystal Character Display (LCD) using the Arduino Development Environment
      9. 4.5.9 High Power DC Devices
    6. 4.6 DC Solenoid Control
    7. 4.7 DC Motor Speed and Direction Control
      1. 4.7.1 DC Motor Operating Parameters
      2. 4.7.2 H–bridge direction control
      3. 4.7.3 Servo motor interface
      4. 4.7.4 Stepper motor control
      5. 4.7.5 AC Devices
    8. 4.8 Interfacing to Miscellaneous Devices
      1. 4.8.1 Sonalerts, Beepers, Buzzers
      2. 4.8.2 Vibrating Motor
    9. 4.9 Application: Special Effects LED Cube
      1. 4.9.1 Construction Hints
      2. 4.9.2 LED Cube Arduino Sketch Code
    10. 4.10 Summary
    11. 4.11 References
    12. 4.12 Chapter Problems
  13. 5 Analog to Digital Conversion (ADC)
    1. 5.1 Overview
    2. 5.2 Sampling, Quantization and Encoding
      1. 5.2.1 Resolution and Data Rate
    3. 5.3 Analog–to–Digital Conversion (ADC) Process
      1. 5.3.1 Transducer Interface Design (TID) Circuit
      2. 5.3.2 Operational Amplifiers
    4. 5.4 ADC Conversion Technologies
      1. 5.4.1 Successive–Approximation
    5. 5.5 The Atmel ATmega328 and ATmega2560 ADC System
      1. 5.5.1 Block Diagram
      2. 5.5.2 ATmega328 ADC Registers
      3. 5.5.3 ATmega2560 ADC Registers
    6. 5.6 Programming the ADC using the Arduino Development Environment
    7. 5.7 ATmega328: Programming the ADC in C
    8. 5.8 ATmega2560: Programming the ADC in C
    9. 5.9 Example: ADC Rain Gage Indicator with the Arduino UNO R3
      1. 5.9.1 ADC Rain Gage Indicator using the Arduino Development Environment
      2. 5.9.2 ADC Rain Gage Indicator in C
      3. 5.9.3 ADC Rain Gage using the Arduino Development Environment–Revisited
    10. 5.10 One–bit ADC – Threshold Detector
    11. 5.11 Digital–to–Analog Conversion (DAC)
      1. 5.11.1 DAC with the Arduino Development Environment
      2. 5.11.2 DAC with external converters
      3. 5.11.3 Octal Channel, 8–bit DAC via the SPI
    12. 5.12 Application: Art piece illumination system – Revisited
    13. 5.13 Arduino Mega 2560 example: Kinesiology and Health Laboratory Instrumentation
    14. 5.14 Summary
    15. 5.15 References
    16. 5.16 Chapter Problems
  14. 6 Interrupt Subsystem
    1. 6.1 Overview
      1. 6.1.1 ATmega328 Interrupt System
      2. 6.1.2 ATmega2560 Interrupt System
      3. 6.1.3 General interrupt response
    2. 6.2 Interrupt programming overview
    3. 6.3 Programming ATmega328 Interrupts in C and the Arduino Development Environment
      1. 6.3.1 External interrupt programming–Atmega328
      2. 6.3.2 ATmega328 Internal Interrupt Programming
    4. 6.4 Programming ATmega2560 Interrupts in C and the Arduino Development Environment
      1. 6.4.1 External interrupt programming–Atmega2560
      2. 6.4.2 ATmega2560 Internal Interrupt Programming
    5. 6.5 Foreground and Background Processing
    6. 6.6 Interrupt Examples
      1. 6.6.1 Application 1: Real Time Clock in C
      2. 6.6.2 Application 2: Real Time Clock using the Arduino Development Environment
      3. 6.6.3 Application 3: Interrupt Driven USART in C
    7. 6.7 Summary
    8. 6.8 References
    9. 6.9 Chapter Problems
  15. 7 Timing Subsystem
    1. 7.1 Overview
    2. 7.2 Timing related terminology
      1. 7.2.1 Frequency
      2. 7.2.2 Period
      3. 7.2.3 Duty Cycle
    3. 7.3 Timing System Overview
    4. 7.4 Timer System Applications
      1. 7.4.1 Input Capture – Measuring External Timing Event
      2. 7.4.2 Counting Events
      3. 7.4.3 Output Compare – Generating Timing Signals to Interface External Devices
      4. 7.4.4 Industrial Implementation Case Study (PWM)
    5. 7.5 Overview of the Atmel ATmega328 and ATmega2560 Timer Systems
    6. 7.6 Timer 0 System
      1. 7.6.1 Modes of Operation
      2. 7.6.2 Timer 0 Registers
    7. 7.7 Timer 1
      1. 7.7.1 Timer 1 Registers
    8. 7.8 Timer 2
    9. 7.9 Programming the Arduino UNO R3 and Mega 2560 using the built–in Arduino Development Environment Timing Features
    10. 7.10 Programming the Timer System in C
      1. 7.10.1 Precision Delay in C
      2. 7.10.2 Pulse Width Modulation in C
      3. 7.10.3 Input Capture Mode in C
    11. 7.11 Apprlication 1: Servo Motor Control with the PWM System in C
    12. 7.12 Application 2: Inexpensive Laser Light Show
    13. 7.13 Summary
    14. 7.14 References
    15. 7.15 Chapter Problems
  16. 8 Serial Communication Subsystem
    1. 8.1 Overview
    2. 8.2 Serial Communications
    3. 8.3 Serial Communication Terminology
    4. 8.4 Serial USART
      1. 8.4.1 System Overview
    5. 8.5 System Operation and Programming using Arduino Development Environment features
    6. 8.6 System Operation and Programming in C
      1. 8.6.1 Serial Peripheral Interface–SPI
    7. 8.7 SPI Programming in the Arduino Development Environment
    8. 8.8 SPI Programming in C
    9. 8.9 Two–wire Serial Interface–TWI
      1. 8.9.1 Arduino Development Environment
    10. 8.10 Application 1: USART communication with LCD
    11. 8.11 Application 2: SD/MMC card module extension via the USART
    12. 8.12 Application 3: Equipping an Arduino Processor with a Voice Chip
    13. 8.13 Application 4: Programming the Arduino UNO R3 ATmega328 via the ISP
      1. 8.13.1 Programming Procedure
    14. 8.14 Application 5: TMS1803 3–bit LED Drive Controller
    15. 8.15 Summary
    16. 8.16 References
    17. 8.17 Chapter Problems
  17. 9 Extended Examples
    1. 9.1 Overview
    2. 9.2 Extended Example 1: Automated Fan Cooling System
    3. 9.3 Extended Example 2: Fine Art Lighting System
    4. 9.4 Extended Example 3: Flight Simulator Panel
    5. 9.5 Extended Example 4: Submersible Robot
      1. 9.5.1 Requirements
      2. 9.5.2 Structure chart
      3. 9.5.3 Circuit Diagram
      4. 9.5.4 UML Activity Diagram
      5. 9.5.5 Microcontroller Code
      6. 9.5.6 Project Extensions
    6. 9.6 Extended example 5: Weather Station
      1. 9.6.1 Requirements
      2. 9.6.2 Structure chart
      3. 9.6.3 Circuit diagram
      4. 9.6.4 UML activity diagrams
      5. 9.6.5 Microcontroller code
    7. 9.7 Autonomous Maze Navigating Robots
    8. 9.8 Extended Example 6: Blinky 602A robot–revisited
      1. 9.8.1 Requirements
      2. 9.8.2 Circuit diagram
      3. 9.8.3 Structure chart
      4. 9.8.4 UML activity diagrams
      5. 9.8.5 Microcontroller code
    9. 9.9 Extended Example 7: Mountain Maze Navigating Robot
      1. 9.9.1 Description
      2. 9.9.2 Requirements
      3. 9.9.3 Circuit diagram
      4. 9.9.4 Structure chart
      5. 9.9.5 UML activity diagrams
      6. 9.9.6 Microcontroller code
      7. 9.9.7 Mountain Maze
      8. 9.9.8 Project extensions
    10. 9.10 Extended Example 8: Robot Wheel Odometry
    11. 9.11 Summary
    12. 9.12 References
    13. 9.13 Chapter Problems
  18. A ATmega328 Register Set
  19. B ATmega328 Header File
  20. C ATmega2560 Register Set
  21. D ATmega2560 Header File
  22. Author’s Biography