Book Image

Learn Arduino Prototyping in 10 days

By : Kallol Bosu Roy Choudhuri
Book Image

Learn Arduino Prototyping in 10 days

By: Kallol Bosu Roy Choudhuri

Overview of this book

This book is a quick, 10-day crash course that will help you become well acquainted with the Arduino platform. The primary focus is to empower you to use the Arduino platform by applying basic fundamental principles. You will be able to apply these principles to build almost any type of physical device. The projects you will work through in this book are self-contained micro-controller projects, interfacing with single peripheral devices (such as sensors), building compound devices (multiple devices in a single setup), prototyping standalone devices (powered from independent power sources), working with actuators (such as DC motors), interfacing with an AC-powered device, wireless devices (with Infrared, Radio Frequency and GSM techniques), and finally implementing the Internet of Things (using the ESP8266 series Wi-Fi chip with an IoT cloud platform). The first half of the book focuses on fundamental techniques and building basic types of device, and the final few chapters will show you how to prototype wireless devices. By the end of this book, you will have become acquainted with the fundamental principles in a pragmatic and scientific manner. You will also be confident enough to take up new device prototyping challenges.
Table of Contents (13 chapters)

Using Arduino interrupts

So far, we have seen how to use the push buttons to change the speed of the DC motor. The previous sketch is written to continuously loop and check for the state of each push button one by one in a sequential manner. First the sketch checks button 1, followed by button 2, and then button 3 - this sequence of checking the state of the buttons continues endlessly. This method of checking for user input may lead to timing issues. Let us understand how.

Let us say you press button 3 (to stop the motor) and at that point in time, if the sketch was checking the state of button 1, then we would have to wait for the sketch to first finish checking button 1, then button 2, and finally button 3 would be checked. Since our sketch is small in size and not doing too many things, you will hardly notice any issues. However, in real-world situations, this is not an ideal...