Far Inside The Arduino

I wrote an Arduino programming book for people who really want to know what is going on -- the Arduino library does it's best to hide the internals. I'm selling this book either printed or Kindle ebook on Amazon here or on your nearest Amazon site if you are not in the US. In the US the price is $19.99 for the Kindle version and $24.99 for the printed version.

Here is the preface of the book, which gives a good idea about its aim:

Have you ever wondered what really goes on inside the microcontroller on the Arduino Uno board? Do you wonder what more it can do beyond the Arduino library functions provided? The author taught college microcontroller courses for 20 years. Starting with industrial microcontroller boards and ending up with boards that students bought (at $150 each) he rejected using a $22 Arduino board in class. Why? Because it was designed to hide the operation of the microcontroller rather than reveal it!


Let's be upfront with what this book is not:


When you start reading this book you are assumed to already have an Arduino Uno or Nano (or equivalent clone), the Arduino IDE installed, and are able to write, load, and run sketches. This book is also useful for the Arduino Mega with the ATmega2560 microcontroller. Some example programs will not work on the Mega board without modification.


So then, what is this book about?


With this knowledge you can improve performance markedly, allowing larger, more sophisticated applications to be implemented. And because all microcontrollers are similar, you will be able to quickly adapt to other microcontrollers you will come across either as a hobbyist or on the job.


There are over 80 example programs. These can be downloaded from the author's website. In most cases only excerpts are in the book to keep the size down.


A few other things to get out of the way:


Let's get started!



Cover Image

Here is the Table of Contents:

The Many Faces of Arduino

The Arduino Uno Board

The Arduino IDE

File Locations

The Arduino Library

AVR Basics

Arduino Uno to ATmega328 "Rosetta Stone"

Harvard Architecture

Lock and Fuse Bits

Accessing I/O Device Registers

EEPROM

Differences in the Arduino MEGA 2560

Loading Programs

Using the Arduino Bootloader

Using a Programmer

Variables and Constants

Data types

Using program memory for constants

Strings or strings?

Digital I/O Pins

Arduino's digitalRead and digitalWrite

The AVR Underpinnings

An Improvement Without Cost

Pulsing A Pin

Special Considerations

Introduction to Interrupts

What is an Interrupt?

Finite State Machines

Simple Multitasking and Execution Blocking

A Basic Multitasking Example

Watchdog Timer

Volatile Variables, Atomic References, and Reentrancy

External Interrupts and attachInterrupt()

The Versatile Timer/Counters

Introduction to Timer/Counters

Arduino Time Measurement

Timer Interrupt and State Machines

The Stepper Motor

Arduino Square Wave Generation - tone()

Generating Square Waves

Arduino PWM Generation - analogWrite()

PWM Generation -- Analog Output, LEDs, Motors, Relays

Input Capture and pulseIn()

Use as a Counter

Other Timer/Counter Topics

Analog Input

Arduino's analogRead()

Using the AVR Analog to Digital Converter

Analog Comparator

Differences in the Arduino Nano and Mega

SPI

Serial Peripheral Interfacing

SPI Example Project

Arduino's Approach

Using the AVR Hardware

Bidirectional SPI Example

Microcontroller as SPI Slave

Two Wire Interface AKA I2C

TWI Basics

The ZS-042

The Arduino Wire Library

Using twi.c

Rolling Your Own

Microcontroller as TWI Slave

One Wire Interface

The One Wire Protocol

One Wire without Interrupts

Interrupt Driven One Wire

USART

USART Functionality

Using the Arduino Serial functions

The AVR USART interface

Buffered UART Operation

STDIO

Line Buffering

Additional Examples

Keypads

Ultrasonic Distance Sensors

Rotary Encoders

LCD Displays

Multiple Relays

Multiple Servos

Multiple Stepper Motors

Waveform Measuring Instrument

Power Saving

References

Index of Example Programs