Learn C Programming for the Arduino and Microcontrollers

advertisement

Beginning C for Arduino: Learn C Programming for the Arduino and Compatible Microcontrollers


Book description

Learn C Programming for the Arduino and Microcontrollers  


    Beginning C for Arduino is written for those who have no prior experience with microcontrollers or programming but would like to experiment and learn both. This book introduces you to the C programming language, reinforcing each programming structure with a simple demonstration of how you can use C to control the Arduino family of microcontrollers. Author Jack Purdum uses an engaging style to teach good programming techniques using examples that have been honed during his 25 years of university teaching.

Beginning C for Arduino will teach you:

  • The C programming language
  • How to use C to control a microcontroller and related hardware
  • How to extend C by creating your own library routines
advertisement

During the course of the book, you will learn the basics of programming, such as working with data types, making decisions, and writing control loops. You'll then progress onto some of the trickier aspects of C programming, such as using pointers effectively, working with the C preprocessor, and tackling file I/O. Each chapter ends with a series of exercises and review questions to test your knowledge and reinforce what you have learned.

What you'll learn

  • The syntax of the C programming language as defined for the Arduino
  • Tried and true coding practices (applicable to any programming language)
  • How to design, code, and debug programs that drive Arduino microcontrollers
  • How to extend the functionality of C
  • How to integrate low cost, off-the-shelf, hardware shields into your own projects

Who this book is for

The book is aimed at a complete novice with no programming background. It assumes no prior programming or hardware design experience and is written for creative and curious people who would like to blend a software and hardware learning experience into a single, enjoyable endeavor.


Robotics with Raspberry Pi and Arduino


advertisement


Table of contents


Introduction

Chapter 1: Introduction

  • Assumptions About You
  • What You Need
  • Verifying the Software
  • Verifying the Hardware
  • Loading and Running Your First Program
  • Summary

Chapter 2: Arduino C

  • The Building Blocks of All Programming Languages
  • The Five Program Steps
  • A Revisit to the Blink Program
  • Summary
  • Exercises

Chapter 3: Arduino C Data Types

  • The boolean Data Type
  • The char Data Type
  • The byte Data Type
  • The int Data Type
  • The word Data Type
  • The long Data type
  • The float and double Data Types
  • The string Data Type
  • String Data Type
  • The void Data Type
  • The array Data Type
  • Defining versus Declaring Variables
  • Using the cast Operator

Chapter 4: Decision Making in C

  • Relational Operators
  • The if Statement
  • A Modified Blink Program
  • Software Modifications to the Alternate Blink Program
  • The if-else Statement
  • Cascading if Statements
  • The Increment and Decrement Operators
  • The switch Statement
  • The goto Statement
  • Getting Rid of Magic Numbers
  • The C Preprocessor
  • Heads or Tails
  • Something to Think About
  • Summary
  • Exercises

Chapter 5: Program Loops in C

  • The Characteristics of Well-Behaved Loops
  • Using a for Loop
  • The while Loop
  • The do-while Loop
  • The break and continue Keywords
  • A Complete Code Example
  • Loops and Coding Style
  • Summary
  • Exercises

Chapter 6: Functions in C

  • The Anatomy of a Function
  • What Makes a “Good” Function
  • Writing Your Own Functions
  • Logical Operators
  • Writing Your Function
  • Leap Year Calculation Program
  • Passing Data Into and Back From a Function
  • Summary
  • Exercises

Chapter 7: Storage Classes and Scope

  • Hiding Your Program Data
  • Statement Block Scope
  • Local Scope
  • Global Scope
  • Scope and Storage Classes
  • The volatile keyword
  • Summary
  • Exercises

Chapter 8: Introduction to Pointers

  • Defining a Pointer
  • Using a Pointer
  • Summary of Pointer Rules
  • Why Are Pointers Useful?
  • Pointers and Arrays
  • Summary
  • Exercises

Chapter 9: Using Pointers Effectively

  • Relational Operations and Test for Equality Using Pointers
  • Pointer Arithmetic
  • Two-Dimensional Arrays
  • Two-Dimensional Arrays and Pointers
  • Pointers to Functions
  • The Right-Left Rule
  • Summary
  • Exercises

Chapter 10: Structures, Unions, and Data Storage

  • Structures
  • Unions
  • EEPROM Memory
  • Data Logging
  • Other Storage Alternatives
  • Summary
  • Exercises

Chapter 11: The C Preprocessor and Bitwise Operations

  • Preprocessor Directives
  • Parameterized Macros
  • Summary
  • Exercises

Chapter 12: Arduino Libraries

  • Libraries
  • Writing Your Own Library
  • Setting the Arduino IDE to Use Your Library
  • A Sample Program Using the Dates Library
  • Summary
  • Exercises


Download full PDF in Comment section

advertisement

1 Comments

Previous Post Next Post