| Table of Contents | 5 |
---|
| About the Author | 14 |
---|
| About the Technical Reviewer | 15 |
---|
| Preface | 16 |
---|
| Chapter 1: Introduction | 17 |
---|
| 1.1. Arduino Installation Paths | 18 |
| 1.2. Coding Style | 20 |
| 1.3. The Arduino Language | 22 |
| 1.4. Coming Up | 22 |
| Chapter 2: Arduino Compilation | 25 |
---|
| 2.1. Preferences.txt | 25 |
| 2.1.1. Using an ICSP for All Uploads | 28 |
| 2.1.2. Change the Action of Home and End Keys | 30 |
| 2.1.3. Setting Tab Stops | 31 |
| 2.2. Globally Defined Paths | 32 |
| 2.3. Boards.txt | 34 |
| 2.3.1. Arduino Uno Example | 34 |
| 2.3.1.1. Board Identifier | 36 |
| 2.3.1.2. Identification Settings | 36 |
| 2.3.1.3. Upload Settings | 38 |
| 2.3.1.4. Bootloader Settings | 39 |
| 2.3.1.4.1. Boards.local.txt | 41 |
| 2.3.1.5. Build Settings | 41 |
| 2.3.1.6. Configuring an ICSP | 43 |
| 2.4. Platform.txt | 44 |
| 2.4.1. Build Recipes | 45 |
| 2.4.2. Pre- and Post-build Hooks | 50 |
| 2.5. Programmers.txt | 52 |
| 2.6. Compiling a Sketch | 55 |
| 2.6.1. Arduino Sketch (*.ino) Preprocessing | 55 |
| 2.6.2. Arduino Sketch (*.ino) Build | 57 |
| 2.7. The Arduino main() Function | 60 |
| 2.8. Header File Arduino.h | 63 |
| 2.8.1. Header File avr\pgmspace.h | 65 |
| 2.8.2. Header File avr\io.h | 65 |
| 2.8.2.1. Header File avr/iom328p.h | 66 |
| 2.8.2.2. Header File avr/portpins.h | 66 |
| 2.8.2.3. Header File | 66 |
| 2.8.2.3. Header File | 66 |
| 67 | 66 |
---|
| 2.8.2.4. Header File | 66 |
| 2.8.2.4. Header File | 66 |
| 67 | 66 |
---|
| 2.8.2.5. Header File | 66 |
| 2.8.2.5. Header File | 66 |
| 68 | 66 |
---|
| 2.8.2.6. Header File | 66 |
| 2.8.2.6. Header File | 66 |
| 68 | 66 |
---|
| 2.8.3. Header File avr\interrupt.h | 68 |
| 2.8.4. Header File binary.h | 69 |
| 2.8.5. Header File WCharacter.h | 71 |
| 2.8.6. Header File WString.h | 72 |
| 2.8.7. Header File HardwareSerial.h | 72 |
| 2.8.8. Header File USBAPI.h | 73 |
| 2.8.9. Header File pins_arduino.h | 73 |
| 2.9. The init() Function | 75 |
| 2.9.1. Enabling the Global Interrupt Flag | 75 |
| 2.9.2. Enabling Timer/counter 0 | 76 |
| 2.9.3. Timer/counter 0 Overflow Interrupt | 79 |
| 2.9.4. Configuring Timer/counter 1 and Timer/counter 2 | 83 |
| 2.9.5. Initializing the Analogue to Digital Converter | 86 |
| 2.9.6. Disabling the USART | 88 |
| Chapter 3: Arduino Language Reference | 89 |
---|
| 3.1. Digital Input/Output | 91 |
| 3.1.1. Function pinMode() | 91 |
| 3.1.2. Function digitalRead() | 100 |
| 3.1.3. Function digitalWrite() | 103 |
| 3.2. Analogue Input/Output | 106 |
| 3.2.1. Function analogReference() | 106 |
| 3.2.2. Function analogRead() | 109 |
| 3.2.3. Function analogWrite() | 113 |
| 3.3. Advanced Input/Output | 120 |
| 3.3.1. Function tone() | 120 |
| 3.3.2. Function noTone() | 135 |
| 3.3.3. Function pulseIn() | 138 |
| 3.3.4. Function pulseInLong() | 146 |
| 3.3.5. Function shiftIn() | 150 |
| 3.3.6. Function shiftOut() | 153 |
| 3.4. Time | 156 |
| 3.4.1. Function delay() | 157 |
| 3.4.2. Function delayMicroseconds() | 163 |
| 3.4.3. Function micros() | 167 |
| 3.4.4. Function millis() | 170 |
| 3.5. Interrupts | 173 |
| 3.5.1. Function interrupts() | 173 |
| 3.5.2. Function noInterrupts() | 174 |
| 3.5.3. Function attachInterrupt() | 174 |
| 3.5.4. Function detachInterrupt() | 185 |
| 3.6. Bits and Bobs | 187 |
| 3.6.1. Macro bit() | 187 |
| 3.6.2. Macro bitClear() | 189 |
| 3.6.3. Macro bitRead() | 189 |
| 3.6.4. Macro bitSet() | 190 |
| 3.6.5. Macro bitWrite() | 190 |
| 3.6.6. Macro highByte() | 191 |
| 3.6.7. Macro lowByte() | 191 |
| 3.6.8. Macro sbi() | 192 |
| 3.6.9. Macro cbi() | 193 |
| Chapter 4: Arduino Classes | 195 |
---|
| 4.1. The Print Class | 195 |
| 4.1.1. Class Members | 198 |
| 4.1.2. Using the Print Class | 200 |
| 4.2. The Printable Class | 205 |