Programming Arduino Next Steps: Going Further with Sketches, 2nd Edition

Book description

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

Table of contents

  1. Cover
  2. Title Page
  3. Copyright Page
  4. Contents
  5. Preface
  6. Acknowledgments
  7. Introduction
  8. 1 Programming Arduino
    1. What Is Arduino?
    2. Installation and the IDE
      1. Installing the IDE
      2. Blink
    3. A Tour of Arduino
      1. Power Supply
      2. Power Connections
      3. Analog Inputs
      4. Digital Connections
    4. Arduino Boards
      1. Uno and Similar
      2. Big Arduino Boards
      3. Small Arduino Boards
      4. Unofficial Arduinos
    5. Programming Language
    6. Modifying the Blink Sketch
    7. Variables
    8. If
    9. Loops
    10. Functions
    11. Digital Inputs
    12. Digital Outputs
    13. The Serial Monitor
    14. Arrays and Strings
    15. Analog Inputs
    16. Analog Outputs
    17. Using Libraries
    18. Arduino Data Types
    19. Arduino Commands
    20. Summary
  9. 2 Under the Hood
    1. A Brief History of Arduino
    2. Anatomy of an Arduino
    3. AVR Processors
      1. ATmega328
      2. ATmega32u4
      3. ATmega2560
      4. AT91SAM3X8E
    4. Arduino and Wiring
    5. From Sketch to Arduino
    6. AVR Studio
    7. Installing a Bootloader
      1. Burning a Bootloader with AVR Studio and a Programmer
      2. Burning a Bootloader with the Arduino IDE and a Second Arduino
    8. Summary
  10. 3 When Is an Arduino Not an Arduino?
    1. The Arduino IDE’s Extensible Architecture
    2. Adafruit Circuit Playground Express
    3. NodeMCU
    4. ESP32
    5. ATtiny Microcontrollers
      1. ATtiny44
      2. Using an Arduino as a Programmer
      3. Installing ATtinyCore into the IDE
      4. Clocks, Crystals, and Fuses
      5. Minimal Arduino
    6. Summary
  11. 4 Interrupts and Timers
    1. Hardware Interrupts
      1. Interrupt Pins
      2. Interrupt Modes
      3. Enabling Internal Pull-Up
      4. Interrupt Service Routines
      5. Volatile Variables
      6. ISR Summary
    2. Enabling and Disabling Interrupts
    3. Timer Interrupts
    4. Summary
  12. 5 Making Arduino Faster
    1. How Fast Is an Arduino?
    2. Comparing Arduino Boards
    3. Speeding Up Arithmetic
      1. Do You Really Need to Use a Float?
    4. Lookup vs. Calculate
    5. Fast I/O
      1. Basic Code Optimization
      2. Bytes and Bits
      3. ATmega328 Ports
      4. Very Fast Digital Output
      5. Fast Digital Input
    6. Speeding Up Analog Inputs
    7. Summary
  13. 6 Low-Power Arduino
    1. Power Consumption of Arduino Boards
    2. Current and Batteries
    3. Reducing the Clock Speed
    4. Turning Things Off
    5. Sleeping ATmega-Based Arduinos
      1. Narcoleptic
      2. Waking ATmega-Based Arduinos on External Interrupts
    6. ESP8266 Sleeping
    7. ESP32 Sleeping
    8. Use Digital Outputs to Control Power
    9. Summary
  14. 7 Memory
    1. Arduino Memory
    2. Minimizing RAM Usage
      1. Use the Right Data Structures
      2. Store String Constants in Flash Memory
      3. Common Misconceptions
      4. Measure Free Memory
    3. Minimizing Flash Usage
      1. Use Constants
      2. Remove Unwanted Trace
      3. Bypass the Bootloader
    4. Static vs. Dynamic Memory Allocation
    5. Strings
      1. C char Arrays
      2. The Arduino String Object Library
    6. Using EEPROM
      1. EEPROM Example
      2. Using the avr/eeprom.h Library
      3. EEPROM Limitations
    7. Using Flash
    8. Using SD Card Storage
    9. Summary
  15. 8 Interfacing with Arduino
    1. Binary
    2. Arduino Types and Binary
    3. Hexadecimal
    4. Masking Bits
    5. Shifting Bits
    6. Serial Data
    7. Summary
  16. 9 Using I2C
    1. I2C Hardware
    2. The I2C Protocol
    3. The Wire Library
      1. Initializing I2C
      2. Master Sending Data
      3. Master Receiving Data
    4. I2C Examples
      1. TEA5767 FM Radio
      2. Arduino-to-Arduino Communication
      3. LED Backpack Boards
      4. DS1307 Real-Time Clock
    5. Summary
  17. 10 Interfacing with 1-Wire Devices
    1. 1-Wire Hardware
    2. The 1-Wire Protocol
    3. The OneWire Library
      1. Initializing 1-Wire
      2. Scanning the Bus
    4. Using the DS18B20
    5. Summary
  18. 11 Interfacing with SPI Devices
    1. Bit Manipulation
    2. SPI Hardware
    3. The SPI Protocol
    4. The SPI Library
    5. SPI Example
    6. Summary
  19. 12 Serial UART Programming
    1. Serial Hardware
    2. Serial Protocol
    3. The Serial Commands
    4. The SoftwareSerial Library
    5. Serial Examples
      1. Computer to Arduino over USB
      2. Arduino to Arduino
      3. GPS Module
    6. Summary
  20. 13 USB Programming
    1. Keyboard and Mouse Emulation
      1. Keyboard Emulation
      2. Keyboard Emulation Example
      3. Mouse Emulation
      4. Mouse Emulation Example
      5. USB Host on the Arduino Due
    2. Summary
  21. 14 Network and Internet of Things Programming
    1. Networking Hardware
      1. Ethernet Shield
      2. Arduino Ethernet/EtherTen
    2. The Ethernet Library
      1. Making a Connection
      2. Setting Up a Web Server
      3. Making Requests
    3. Wired Ethernet Examples
      1. Physical Web Server
      2. Using a JSON Web Service
    4. The Official Arduino WiFi Library
      1. Making a Connection
      2. WiFi-Specific Functions
    5. Arduino WiFi Example
    6. ESP8266/ESP32 WiFi Example
    7. Internet of Things
      1. dweet.io
      2. Programming the NodeMCU or Wemos D1 Mini
      3. Attaching the TMP36
      4. A Web Page to Display the Temperature
    8. Summary
  22. 15 Digital Signal Processing
    1. Introducing Digital Signal Processing
    2. Averaging Readings
    3. An Introduction to Filtering
    4. Creating a Simple Low-Pass Filter
    5. Arduino Uno DSP
    6. Arduino Due DSP
    7. Filter Code Generation
    8. The Fourier Transform
      1. Spectrum Analyzer Example
      2. Frequency Measurement Example
    9. Summary
  23. 16 Managing with One Process
    1. Making the Transition from Big Programming
    2. Why You Don’t Need Threads
    3. Setup and Loop
      1. Sense Then Act
      2. Pause Without Blocking
    4. The Timer Library
    5. State Diagrams
    6. State Machines in Arduino
    7. Summary
  24. 17 Writing Libraries
    1. When to Make a Library
    2. Using Classes and Methods
    3. Library Example (TEA5767 Radio)
      1. Define the Library’s Interface
      2. Write the Header File
      3. Write the Implementation File
      4. Write the Keywords File
      5. Make the Examples Folder
    4. Testing the Library
    5. Releasing the Library
    6. Publishing Your Library on GitHub
      1. GitHub
      2. Creating a Repository
    7. Summary
  25. A Parts
    1. Arduino Boards
    2. Components and Modules
    3. Suppliers
    4. Arduino Starter Kits
  26. Index

Product information

  • Title: Programming Arduino Next Steps: Going Further with Sketches, 2nd Edition
  • Author(s): Simon Monk
  • Release date: November 2018
  • Publisher(s): McGraw-Hill Education TAB
  • ISBN: 9781260143256