O'Reilly logo

Arduino For Dummies, 2nd Edition by John Nussey

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 10

Getting Clever with Code

IN THIS CHAPTER

check Understanding timers

check Debouncing your buttons

check Getting more from your buttons

check Averaging your results

check 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.

Blinking Better

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 that it can get even better? The basic Blink sketch presented in Chapter 3 performs its task well, with one significant drawback: It can’t do anything else while blinking.

Take a look at the Blink sketch again:

void setup() {

// initialize digital ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required