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

Finding logic bugs in your code - Arduino Tutorial

From the course: Learning Arduino: Pulse Width Modulation

Start my 1-month free trial

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…

Contents