One Circuit, a Thousand Behaviours

The great advantage of programmable electronics over classic electronics now becomes evident: I will show you how to implement many different “behaviours” using the same electronic circuit as in the previous section, just by changing the software. As I’ve mentioned before, it’s not very practical to have to hold your finger on the button to… Continue reading One Circuit, a Thousand Behaviours

How Does This Work?

We have introduced two new concepts with this example program: functions that return the result of their work, and the if statement. The if statement is possibly the most important instruction in a programming language, because it allows a computer (and remember, the Arduino is a small computer) to make decisions. After the if keyword, you have to write a “question”… Continue reading How Does This Work?

What Is Electricity?

If you have done any plumbing at home, electronics won’t be a problem for you to understand. To understand how electricity and electric circuits work, the best way is to use something called the water analogy. Let’s take a simple device, like the battery-powered portable fan shown in Figure 4-3. If you take a fan apart, you will see… Continue reading What Is Electricity?

The Code, Step by Step

At first, you might consider this kind of explanation too unnecessary, a bit like when I was in school and I had to study Dante’s Divina Commedia (every Italian student has to go through that, as well as another book called I promessi sposi, or The Betrothed—oh, the nightmares). For each line of the poems, there were a hundred lines… Continue reading The Code, Step by Step

Arduino Is Not for Quitters

Arduino always expects that you’ve created two functions: one called setup() and one called loop(). setup() is where you put all the code that you want to execute once at the beginning of your program, and loop() contains the core of your program, which is executed over and over again. This is done because Arduino is not like your regular computer—it… Continue reading Arduino Is Not for Quitters

Blinking an LED

The LED blinking sketch is the first program that you should run to test whether your Arduino board is working and is configured correctly. It is also usually the very first programming exercise someone does when learning to program a microcontroller. A light-emitting diode (LED) is a small electronic component that’s a bit like a lightbulb, but… Continue reading Blinking an LED