Log In
Or create an account ->
Imperial Library
Home
About
News
Upload
Forum
Help
Login/SignUp
Index
Coverpage
Titlepage
Copyright
Dedication
Contents at a Glance
Contents
About the Author
About the Technical Reviewer
Acknowledgments
Introduction
Chapter 1: Introduction
Assumptions About You
What You Need
An Atmel-Based Microcontroller Card
Breadboard
Miscellaneous Parts
Verifying the Software
Verifying the Hardware
Attaching the USB Cable
Selecting Your µc Board in the Integrated Development Environment
Port Selection
Loading and Running Your First Program
The Blink Program
Running the Blink Program Code
Compiling the Blink Program Code
Uploading the Blink Program
Summary
Chapter 2: Arduino C
The Building Blocks of All Programming Languages
Expressions
Statements
Statement Blocks
Function Blocks
The Five Program Steps
1. Initialization Step
2. Input Step
3. Process Step
4. Output Step
5. Termination Step
The Purpose of the Five Program Steps
A Revisit to the Blink Program
Program Comments
Data Definition
The setup() Function
The loop() Function
Summary
Exercises
Chapter 3: Arduino C Data Types
Keywords in C
Variable Names in C
The boolean Data Type
The char Data Type
Binary Data
The char Data Type and Character Sets
Generating a Table of ASCII Characters
The byte Data Type
The int Data Type
The word Data Type
The long Data type
The float and double Data Types
Floating Point Precision
The string Data Type
String Data Type
The void Data Type
The array Data Type
Defining versus Declaring Variables
Symbol Tables
lvalues and rvalues
The Bucket Analogy
Using the cast Operator
Summary
Exercises
Chapter 4: Decision Making in C
Relational Operators
The if Statement
A Modified Blink Program
The Circuit
The Program Code
Software Modifications to the Alternate Blink Program
The if-else Statement
Cascading if Statements
The Increment and Decrement Operators
Two Types of Increment Operator (++)
Two Flavors of the Decrement Operator (--)
Precedence of Operators
The switch Statement
The goto Statement
Getting Rid of Magic Numbers
The C Preprocessor
Heads or Tails
Initialization Step
Input Step
Process Step
Output Step
Termination Step
Something to Think About
Summary
Exercises
Chapter 5: Program Loops in C
The Characteristics of Well-Behaved Loops
Condition 1: Variable Initialization
Condition 2: Loop Control Test
Condition 3: Changing the Loop Control Variable's State
Using a for Loop
The while Loop
The do-while Loop
The break and continue Keywords
The break Statement
The continue Statement
A Complete Code Example
Step 1. Initialization
Step 2. Input
Step 3. Process
Step 4. Output
Step 5. Termination
Listing 5-1 is Sorta Dumb Code
Loops and Coding Style
Summary
Exercises
Chapter 6: Functions in C
The Anatomy of a Function
Function Type Specifier
Function Name
Function Arguments
Function Body
Function Signature
What Makes a “Good” Function
Functions Use Task-Oriented Names
The Function Should Be Cohesive
Functions Should Avoid Coupling
Writing Your Own Functions
Function Design Considerations
Argument List
Function Body
Logical Operators
Logical AND Operator (&&)
Logical OR (||)
Logical NOT (!)
Writing Your Function
The IsLeapYear() Function and Coding Style
Arguments versus Parameters
Why Use a Specific Function Style?
Leap Year Calculation Program
Passing Data Into and Back From a Function
Pass by Value
Summary
Exercises
Chapter 7: Storage Classes and Scope
Hiding Your Program Data
Statement Block Scope
Local Scope
Name Collisions and Scope
Global Scope
Global Scope and Name Conflicts
Scope and Storage Classes
The auto Storage Class
The register Storage Class
The static Storage Class
The extern Storage Class
The volatile keyword
Summary
Exercises
Chapter 8: Introduction to Pointers
Defining a Pointer
Pointer Name
Asterisk
Pointer Type Specifiers and Pointer Scalars
Using a Pointer
The Indirection Operator (*)
Using Indirection
Summary of Pointer Rules
Why Are Pointers Useful?
Pointers and Arrays
The Importance of Scalars
Summary
Exercises
Chapter 9: Using Pointers Effectively
Relational Operations and Test for Equality Using Pointers
Pointer Comparisons Must be Between Pointers to the Same Data
Pointer Arithmetic
Constant lvalues
Two-Dimensional Arrays
A Small Improvement
How Many Dimensions?
Two-Dimensional Arrays and Pointers
Treating the Two-Dimensional Array of chars as a String
Pointers to Functions
Arrays of Pointers to Functions
enum Data Type
The Right-Left Rule
Summary
Exercises
Chapter 10: Structures, Unions, and Data Storage
Structures
Declaring a Structure
Defining a Structure
Accessing Structure Members
Returning a Structure from a Function Call
Using Structure Pointers
Initializing a Structure
Arrays of Structures
Unions
EEPROM Memory
Using EEPROM
Data Logging
Other Storage Alternatives
Shields
Other Uses for Secure Digital Storage
Summary
Exercises
Chapter 11: The C Preprocessor and Bitwise Operations
Preprocessor Directives
#undef
#line
#if, Conditional Directives
#include
Parameterized Macros
Bitwise Operators
Bitwise Shift Operators
Using Different Bases for Integer Constants
Parameterized Macros...continued
Summary
Exercises
Chapter 12: Arduino Libraries
Libraries
Arduino Libraries
The Arduino Core Libraries
Other Libraries
Writing Your Own Library
The Library Header File
The Library Code File (Dates.cpp)
Setting the Arduino IDE to Use Your Library
A Sample Program Using the Dates Library
Adding the Easter Program to the IDE
The keywords.txt File
Keyword Coloring (theme.txt)
Summary
Exercises
Appendix A: Suppliers and Sources
Suppliers
Seeedino Studio
Diligent Inc
OSEPP
Tinyos Electronics
Cooking Hacks
Sources
Software
Appendix B: Electronic Components for Experiments
Microcontroller Board
Solderless Breadboard
Electronic Components
Online Component Purchases
Experiment!
Answers to Exercises
Chapter 2
Chapter 3
Chapter 4
Chapter 5
Chapter 6
Chapter 7
Chapter 8
Chapter 9
Chapter 10
Chapter 11
Chapter 12
Index
← Prev
Back
Next →
← Prev
Back
Next →