Acknowledgments |
|
xvii | |
Introduction |
|
xix | |
|
|
1 | (28) |
|
The Possibilities Are Endless |
|
|
2 | (2) |
|
The Microchip AVR Microcontrollers |
|
|
4 | (2) |
|
Required Parts and Accessories |
|
|
6 | (2) |
|
|
7 | (1) |
|
Choosing an AVR Programmer |
|
|
7 | (1) |
|
|
8 | (7) |
|
|
9 | (1) |
|
Ubuntu Linux 20.04 LTS or Later |
|
|
10 | (1) |
|
|
11 | (4) |
|
Current, Voltage, and Power |
|
|
15 | (1) |
|
|
15 | (14) |
|
|
16 | (3) |
|
|
19 | (1) |
|
|
20 | (1) |
|
|
21 | (2) |
|
|
23 | (1) |
|
|
24 | (1) |
|
|
25 | (4) |
|
|
29 | (28) |
|
Testing the Hardware and Toolchain |
|
|
30 | (6) |
|
|
30 | (3) |
|
Connect and Run the Programmer |
|
|
33 | (2) |
|
|
35 | (1) |
|
Project 0 Blinking an Led |
|
|
36 | (3) |
|
Uploading Your First AVR Code |
|
|
36 | (2) |
|
|
38 | (1) |
|
Controlling Digital Outputs |
|
|
39 | (2) |
|
|
39 | (2) |
|
Project 1 Experimenting with ATtiny85 Digital Outputs |
|
|
41 | (2) |
|
|
42 | (1) |
|
|
42 | (1) |
|
|
43 | (4) |
|
|
44 | (1) |
|
|
45 | (1) |
|
|
46 | (1) |
|
Project 2 Experimenting with ATmega328P-PU Digital Outputs |
|
|
47 | (3) |
|
|
47 | (2) |
|
|
49 | (1) |
|
Project 3 Bit-Shifting Digital Outputs |
|
|
50 | (3) |
|
Project 4 Experimenting with NOT |
|
|
53 | (1) |
|
Project 5 Experimenting with AND |
|
|
54 | (1) |
|
Project 6 Experimenting with OR |
|
|
55 | (1) |
|
Project 7 Experimenting with XOR |
|
|
56 | (1) |
|
3 Getting and Displaying Input |
|
|
57 | (34) |
|
|
58 | (1) |
|
Introducing the Pushbutton |
|
|
58 | (1) |
|
Reading the Status of Digital Input Pins |
|
|
59 | (1) |
|
Project 8 Blinking an LED on Command |
|
|
59 | (2) |
|
|
59 | (1) |
|
|
60 | (1) |
|
|
61 | (2) |
|
|
61 | (1) |
|
|
62 | (1) |
|
Making Two or More Comparisons |
|
|
62 | (1) |
|
Switch ... case Statements |
|
|
63 | (1) |
|
Creating Your Own Functions |
|
|
63 | (1) |
|
Project 9 A Simple Custom Function |
|
|
64 | (1) |
|
Project 10 Custom Functions with Internal Variables |
|
|
65 | (1) |
|
Project 11 Custom Functions That Return Values |
|
|
66 | (2) |
|
|
68 | (1) |
|
Protecting Your AVR from Fluctuating Voltages |
|
|
69 | (1) |
|
|
69 | (1) |
|
|
70 | (1) |
|
Introducing Seven-Segment LED Displays |
|
|
70 | (1) |
|
Project 12 Building a Single-Digit Numerical Counter |
|
|
71 | (3) |
|
|
72 | (1) |
|
|
72 | (2) |
|
|
74 | (1) |
|
|
75 | (1) |
|
Project 13 Making a Single-Cell Battery Tester |
|
|
76 | (3) |
|
|
76 | (1) |
|
|
77 | (2) |
|
Using the ATmega328P-PU ADCs |
|
|
79 | (1) |
|
Introducing the Variable Resistor |
|
|
80 | (2) |
|
Project 14 Experimenting with an ATmega328P-PU ADC |
|
|
82 | (2) |
|
|
82 | (1) |
|
|
83 | (1) |
|
Doing Arithmetic with an AVR |
|
|
84 | (1) |
|
|
85 | (1) |
|
The TMP36 Temperature Sensor |
|
|
86 | (1) |
|
Project 15 Creating a Digital Thermometer |
|
|
87 | (4) |
|
|
87 | (1) |
|
|
88 | (3) |
|
4 Communicating With the Outside World Using the Usart |
|
|
91 | (24) |
|
|
92 | (1) |
|
Hardware and Software for USART Communication |
|
|
93 | (2) |
|
Project 16 Testing the USART |
|
|
95 | (3) |
|
|
95 | (1) |
|
|
96 | (2) |
|
Project 17 Sending Text with the USART |
|
|
98 | (2) |
|
Project 18 Sending Numbers with the USART |
|
|
100 | (2) |
|
Project 19 Creating a Temperature Data Logger |
|
|
102 | (6) |
|
|
102 | (2) |
|
|
104 | (4) |
|
Project 20 Receiving Data from Your Computer |
|
|
108 | (3) |
|
Project 21 Building a Four-Function Calculator |
|
|
111 | (4) |
|
5 Taking Control With Hardware Interrupts |
|
|
115 | (22) |
|
|
116 | (2) |
|
Setting Up Interrupts in Code |
|
|
116 | (2) |
|
Project 22 Experimenting with Rising Edge Interrupts |
|
|
118 | (3) |
|
|
118 | (1) |
|
|
119 | (2) |
|
Project 23 Experimenting with Falling Edge Interrupts |
|
|
121 | (3) |
|
|
121 | (1) |
|
|
122 | (2) |
|
Project 24 Experimenting with Two Interrupts |
|
|
124 | (2) |
|
|
124 | (1) |
|
|
125 | (1) |
|
|
126 | (3) |
|
Project 25 Experimenting with Pin-Change Interrupts |
|
|
129 | (2) |
|
|
129 | (1) |
|
|
130 | (1) |
|
Project 26 Creating an Up/Down Counter Using Interrupts |
|
|
131 | (4) |
|
|
131 | (1) |
|
|
132 | (3) |
|
Final Notes on Interrupts |
|
|
135 | (2) |
|
|
137 | (16) |
|
|
138 | (1) |
|
Project 27 Experimenting with Timer Overflow and Interrupts |
|
|
139 | (7) |
|
|
139 | (1) |
|
|
140 | (1) |
|
Examining the Accuracy of the Internal Timer |
|
|
141 | (1) |
|
Project 28 Using a CTC Timer for Repetitive Actions |
|
|
142 | (1) |
|
Project 29 Using CTC Timers for Repetitive Actions with Longer Delays |
|
|
143 | (4) |
|
Addressing Registers with Bitwise Operations |
|
|
147 | (3) |
|
Addressing Individual Bits in a Register |
|
|
147 | (2) |
|
Addressing Multiple Bits in a Register |
|
|
149 | (1) |
|
Project 30 Experimenting with Overflow Timers Using Bitwise Operations |
|
|
150 | (3) |
|
7 Using Pulse-Width Modulation |
|
|
153 | (16) |
|
Pulse-Width Modulation and Duty Cycles |
|
|
154 | (1) |
|
Project 31 Demonstrating PWM with the ATtiny85 |
|
|
155 | (2) |
|
|
155 | (1) |
|
|
155 | (2) |
|
Individual PWM Pin Control for the ATtiny85 |
|
|
157 | (2) |
|
Project 32 Experimenting with Piezo and PWM |
|
|
159 | (2) |
|
|
159 | (1) |
|
|
160 | (1) |
|
Individual PWM Pin Control for the ATmega328P-PU |
|
|
161 | (2) |
|
|
163 | (1) |
|
Project 33 Experimenting with RGB LEDs and PWM |
|
|
164 | (1) |
|
|
164 | (5) |
|
8 Controlling Motors With Mosfets |
|
|
169 | (20) |
|
|
170 | (1) |
|
Project 34 DC Motor Control with PWM and MOSFET |
|
|
171 | (3) |
|
|
171 | (1) |
|
|
172 | (2) |
|
Project 35 Temperature-Controlled Fan |
|
|
174 | (4) |
|
|
174 | (2) |
|
|
176 | (2) |
|
The L293D Motor Driver IC |
|
|
178 | (2) |
|
Project 36 DC Motor Control with L293D |
|
|
180 | (3) |
|
|
181 | (1) |
|
|
181 | (2) |
|
Project 37 Controlling a Two-Wheel-Drive Robot Vehicle |
|
|
183 | (6) |
|
|
184 | (1) |
|
|
185 | (4) |
|
9 Using the Internal Eeprom |
|
|
189 | (16) |
|
|
190 | (1) |
|
Project 38 Experimenting with the ATtiny 85's Eeprom |
|
|
191 | (1) |
|
|
192 | (1) |
|
Project 39 A Simple EEPROM Datalogger |
|
|
193 | (5) |
|
|
193 | (1) |
|
|
194 | (4) |
|
Storing Floating-Point Variables |
|
|
198 | (1) |
|
Project 40 Temperature Logger with EEPROM |
|
|
199 | (6) |
|
|
199 | (6) |
|
10 Writing Your Own Avr Libraries |
|
|
205 | (14) |
|
Creating Your First Library |
|
|
206 | (2) |
|
|
207 | (1) |
|
|
208 | (1) |
|
Project 41 Your First Library |
|
|
208 | (2) |
|
Creating a Library That Accepts Values to Perform a Function |
|
|
210 | (2) |
|
Project 42 Using the blinko2.c Library |
|
|
212 | (1) |
|
Creating a Library That Processes Data and Returns Values |
|
|
212 | (3) |
|
Project 43 Creating a Digital Thermometer with the thermometer.c Library |
|
|
215 | (4) |
|
|
219 | (30) |
|
|
220 | (3) |
|
Pin Connections and Voltages |
|
|
221 | (1) |
|
|
222 | (1) |
|
|
223 | (1) |
|
Project 44 Using the 74HC595 Shift Register |
|
|
223 | (6) |
|
|
225 | (1) |
|
|
226 | (3) |
|
Project 45 Using Two 74HC595 Shift Registers |
|
|
229 | (2) |
|
|
229 | (1) |
|
|
230 | (1) |
|
Project 46 Using the MAX7219 LED Driver IC |
|
|
231 | (6) |
|
|
231 | (3) |
|
|
234 | (3) |
|
Project 47 Adding a Reset Button |
|
|
237 | (2) |
|
Multiple SPI Devices on the Same Bus |
|
|
239 | (1) |
|
Receiving Data from the SPI Bus |
|
|
239 | (1) |
|
Project 48 Using the MCP3008 ADC IC |
|
|
240 | (9) |
|
|
242 | (1) |
|
|
243 | (6) |
|
|
249 | (32) |
|
|
250 | (2) |
|
|
252 | (4) |
|
Pin Connections and Voltages |
|
|
253 | (1) |
|
|
254 | (2) |
|
Project 49 Using the MCP23017 16-Bit I/O Expander |
|
|
256 | (6) |
|
|
258 | (1) |
|
|
259 | (3) |
|
Reading Data from I2C Devices |
|
|
262 | (1) |
|
Project 50 Using an External IC EEPROM |
|
|
263 | (7) |
|
|
264 | (1) |
|
|
265 | (5) |
|
Project 51 Using the DS3231 Real-Time Clock |
|
|
270 | (11) |
|
|
272 | (1) |
|
|
273 | (8) |
|
13 Avr and Character Liquid Crystal Displays |
|
|
281 | (32) |
|
|
282 | (6) |
|
|
285 | (1) |
|
Initialize the LCD for Use |
|
|
286 | (1) |
|
|
286 | (1) |
|
|
286 | (1) |
|
|
287 | (1) |
|
Project 52 Using a Character LCD with Your AVR |
|
|
288 | (4) |
|
|
288 | (1) |
|
|
289 | (3) |
|
Project 53 Building an AVR-Based LCD Digital Clock |
|
|
292 | (8) |
|
|
292 | (1) |
|
|
293 | (7) |
|
Displaying Floating-Point Numbers on the LCD |
|
|
300 | (1) |
|
Project 54 LCD Digital Thermometer with Min/Max Display |
|
|
301 | (5) |
|
|
301 | (1) |
|
|
302 | (4) |
|
Displaying Custom Characters on the LCD |
|
|
306 | (3) |
|
|
308 | (1) |
|
Send Custom Character Data to LCD |
|
|
308 | (1) |
|
Display Custom Characters on LCD |
|
|
308 | (1) |
|
Project 55 Displaying Custom LCD Characters |
|
|
309 | (4) |
|
|
313 | (20) |
|
|
314 | (3) |
|
|
315 | (1) |
|
|
315 | (2) |
|
Project 56 Experimenting with Servos |
|
|
317 | (3) |
|
|
317 | (1) |
|
|
318 | (2) |
|
Project 57 Creating an Analog Thermometer |
|
|
320 | (3) |
|
|
320 | (2) |
|
|
322 | (1) |
|
Project 58 Controlling Two Servos |
|
|
323 | (3) |
|
|
323 | (1) |
|
|
324 | (2) |
|
Project 59 Building an Analog Clock with Servo Hands |
|
|
326 | (7) |
|
|
326 | (1) |
|
|
327 | (6) |
Epilogue |
|
333 | (2) |
Index |
|
335 | |