Getting Clever with Code
In This Chapter
Debouncing your buttons
Getting more from your buttons
Averaging your results
Adjusting the sensitivity of sensors
As you find different uses and needs for Arduino, you can refine your code to make it more accurate, responsive, and efficient. Also, by thinking about the code in your project, you may be able to avoid or minimize many of the unexpected results that can occur when dealing with physical hardware and the real world. In this chapter, you look at a few sketches that will help you fine-tune your project.
Blink is most likely the first sketch you encountered. It’s a magical moment when that first LED lights up, isn’t it? But what if I told you it that it can get even better? The basic blink sketch presented in Chapter 4 performs its task well, with one significant drawback: It can’t do anything else while blinking.
Take a look at it again:
Turns on an LED on for one second, ...