0%

Book Description

In just 24 sessions of one hour or less, Sams Teach Yourself Arduino Programming in 24 Hours teaches you C programmingon Arduino, so you can start creating inspired “DIY” hardwareprojects of your own! Using this book’s straightforward, step-by-stepapproach, you’ll walk through everything from setting up yourprogramming environment to mastering C syntax and features, interfacing your Arduino to performing full-fledged prototyping.Every hands-on lesson and example builds on what you’ve alreadylearned, giving you a rock-solid foundation for real-world success!

Step-by-step instructions carefully walk you through the most common Arduino programming tasks.

Quizzes at the end of each chapter help you test your knowledge.

By the Way notes present interesting information related to the discussion.

Did You Know? tips offer advice or show you easier ways to perform tasks.

Watch Out! cautions alert you to possible problems and give you advice on how to avoid them.

Learn how to...

  • Get the right Arduino hardware and accessories for your needs

  • Download the Arduino IDE, install it, and link it to your Arduino

  • Quickly create, compile, upload, and run your first Arduino program

  • Master C syntax, decision control, strings, data structures, and functions

  • Use pointers to work with memory—and avoid common mistakes

  • Store data on your Arduino’s EEPROM or an external SD card

  • Use existing hardware libraries, or create your own

  • Send output and read input from analog devices or digital interfaces

  • Create and handle interrupts in software and hardware

  • Communicate with devices via the SPI interface and I2C protocol

  • Work with analog and digital sensors

  • Write Arduino C programs that control motors

  • Connect an LCD to your Arduino, and code the output

  • Install an Ethernet shield, configure an Ethernet connection, and write networking programs

  • Create prototyping environments, use prototyping shields, and interface electronics to your Arduino

  • Table of Contents

    1. About This eBook
    2. Title Page
    3. Copyright Page
    4. Contents at a Glance
    5. Table of Contents
    6. About the Author
    7. Dedication
    8. Acknowledgments
    9. We Want to Hear from You!
    10. Reader Services
    11. Introduction
      1. Programming the Arduino
      2. Who Should Read This Book?
      3. Conventions Used in This Book
    12. Part I: The Arduino Programming Environment
      1. Hour 1. Introduction to the Arduino
        1. What Is an Arduino?
        2. Introducing the Arduino Family
        3. Exploring Arduino Shields
        4. Summary
        5. Workshop
      2. Hour 2. Creating an Arduino Programming Environment
        1. Exploring Microcontroller Internals
        2. Moving Beyond Machine Code
        3. Creating Arduino Programs
        4. Installing the Arduino IDE
        5. Summary
        6. Workshop
      3. Hour 3. Using the Arduino IDE
        1. Overview of the IDE
        2. Walking Through the Menus
        3. Exploring the Toolbar
        4. Exploring the Message Area and Console Window
        5. Setting Up the Arduino IDE
        6. Using the Serial Monitor
        7. Summary
        8. Workshop
      4. Hour 4. Creating an Arduino Program
        1. Building an Arduino Sketch
        2. Creating Your First Sketch
        3. Interfacing with Electronic Circuits
        4. Summary
        5. Workshop
    13. Part II: The C Programming Language
      1. Hour 5. Learning the Basics of C
        1. Working with Variables
        2. Using Operators
        3. Exploring Arduino Functions
        4. Summary
        5. Workshop
      2. Hour 6. Structured Commands
        1. Working with the if Statement
        2. Grouping Multiple Statements
        3. Using else Statements
        4. Using else if Statements
        5. Understanding Comparison Conditions
        6. Creating Compound Conditions
        7. Negating a Condition Check
        8. Expanding with the switch Statement
        9. Summary
        10. Workshop
      3. Hour 7. Programming Loops
        1. Understanding Loops
        2. Using while Loops
        3. Using do-while Loops
        4. Using for Loops
        5. Using Arrays in Your Loops
        6. Using Multiple Variables
        7. Nesting Loops
        8. Controlling Loops
        9. Summary
        10. Workshop
      4. Hour 8. Working with Strings
        1. What’s a String?
        2. Understanding C-Style Strings
        3. Introducing the Arduino String Object
        4. Manipulating String Objects
        5. Summary
        6. Workshop
      5. Hour 9. Implementing Data Structures
        1. What’s a Data Structure?
        2. Creating Data Structures
        3. Using Data Structures
        4. Manipulating Data Structures
        5. Arrays of Structures
        6. Working with Unions
        7. Summary
        8. Workshop
      6. Hour 10. Creating Functions
        1. Basic Function Use
        2. Returning a Value
        3. Passing Values to Functions
        4. Handling Variables in Functions
        5. Calling Functions Recursively
        6. Summary
        7. Workshop
      7. Hour 11. Pointing to Data
        1. What Is a Pointer?
        2. Working with Pointers
        3. Using Special Types of Pointers
        4. Pointer Arithmetic
        5. Strings and Pointers
        6. Combining Pointers and Structures
        7. Using Pointers with Functions
        8. Summary
        9. Workshop
      8. Hour 12. Storing Data
        1. Arduino Memory Refresher
        2. Taking a Closer Look at SRAM
        3. Creating Dynamic Variables
        4. Using Flash to Store Data
        5. Using the EEPROM Memory
        6. Summary
        7. Workshop
      9. Hour 13. Using Libraries
        1. What Is a Library?
        2. Using the Standard Libraries
        3. Using Contributed Libraries
        4. Creating Your Own Libraries
        5. Summary
        6. Workshop
    14. Part III: Arduino Applications
      1. Hour 14. Working with Digital Interfaces
        1. Digital Overview
        2. Using Digital Outputs
        3. Experimenting with Digital Output
        4. Working with Digital Inputs
        5. Experimenting with Digital Input
        6. Summary
        7. Workshop
      2. Hour 15. Interfacing with Analog Devices
        1. Analog Overview
        2. Working with Analog Input
        3. Modifying the Input Result
        4. Using Input Mapping
        5. Changing the Reference Voltage
        6. Analog Output
        7. Using the Analog Output
        8. Summary
        9. Workshop
      3. Hour 16. Adding Interrupts
        1. What Are Interrupts?
        2. Types of Interrupts
        3. Using External Interrupts
        4. Testing External Interrupts
        5. Using Pin Change Interrupts
        6. Working with Timer Interrupts
        7. Ignoring Interrupts
        8. Summary
        9. Workshop
      4. Hour 17. Communicating with Devices
        1. Serial Communication Protocols
        2. Using the Serial Port
        3. Working with the SPI Port
        4. Working with I2C
        5. Summary
        6. Workshop
      5. Hour 18. Using Sensors
        1. Interfacing with Analog Sensors
        2. Working with Voltage
        3. Using a Voltage-Based Sensor
        4. Working with Resistance Output
        5. Using a Resistance-Based Sensor
        6. Using Touch Sensors
        7. Working with Touch Sensors
        8. Summary
        9. Workshop
      6. Hour 19. Working with Motors
        1. Types of Motors
        2. Using DC Motors
        3. Experimenting with Motors
        4. Using Servo Motors
        5. Summary
        6. Workshop
      7. Hour 20. Using an LCD
        1. What Is an LCD?
        2. Interfacing with LCD Devices
        3. The LiquidCrystal Library
        4. The LCD Shield
        5. Summary
        6. Workshop
      8. Hour 21. Working with the Ethernet Shield
        1. Connecting the Arduino to a Network
        2. The Ethernet Shield Library
        3. Writing a Network Program
        4. Summary
        5. Workshop
      9. Hour 22. Advanced Network Programming
        1. The Web Protocol
        2. Reading Sensor Data from a Web Server
        3. Controlling an Arduino from the Web
        4. Summary
        5. Workshop
      10. Hour 23. Handling Files
        1. What Is an SD Card Reader?
        2. SD Cards and the Arduino
        3. The SD Library
        4. Interfacing with the SD Card
        5. Storing Sensor Data
        6. Summary
        7. Workshop
      11. Hour 24. Prototyping Projects
        1. Determining Project Requirements
        2. Determining Interface Requirements
        3. Listing Components
        4. Creating a Schematic
        5. Creating the Breadboard Circuit
        6. Designing the Sketch
        7. Writing the Sketch
        8. Testing the Sketch
        9. Creating a Prototype Board
        10. Summary
        11. Workshop
    15. Index
    18.117.182.179