From the course: Learning Arduino: Pulse Width Modulation
Unlock the full course today
Join today to access over 22,700 courses taught by industry experts or purchase this course individually.
Finding logic bugs in your code - Arduino Tutorial
From the course: Learning Arduino: Pulse Width Modulation
Finding logic bugs in your code
- Consider this. You are working on a project that calls for a potentiometer to control the brightness of an LED. Once you upload your code, regardless of the position of the potentiometer, your LED remains off. What's the problem? You could have a Logic Bug in your program. Logic Bugs are tricky; they are the result of bad math, or faulty logic. Because the code is technically sound, the compiler has no issues with it. You just don't see the actions you expect when it executes. Because it's so easy to make a simple mistake in your head, following along with the code, and doing the math by hand, often leads to logic errors. To squash those bugs, I use the Serial Monitor. While the Serial Monitor can simply be used to print information from the pins on the Arduino, it can also be useful in finding problems in your programming logic or physical components. By printing additional information to the Serial Monitor, you can see how variables are being manipulated throughout your code. In…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Introducing various analog inputs3m 52s
-
(Locked)
Understanding the basics of analog input3m 15s
-
(Locked)
Finding logic bugs in your code3m 40s
-
(Locked)
Testing components with a multimeter3m 31s
-
(Locked)
Using the map function3m 50s
-
(Locked)
Challenge: Understanding the math behind the map function49s
-
(Locked)
Solution: Understanding the math behind the map function1m 15s
-
-
-
-