We've practiced the basic process of working
with sensors in this chapter. Very important stuff for future projects. Making your Arduino designs react to the environment
is pretty cool. You connected sensors to analog pins and learned
how to read values from them with the analogRead command. You used serial communication to monitor those
values, which helped you understand how your code should work. You stored sensor values into variables, which
makes the values easy to use. You used those values to program conditions
with the if statement, and you mapped sensor values to a new range in order to control
different devices. Talking about devices, you used a new command,
analogWrite, to control the brightness of an LED. Nice to know there are more options than just
on and off. You had a chance to experiment when you made
the shadow and light instrument. I hope playing around with the parameters
and conditions in the Arduino program resulted in lots of different sounds. If you decided to continue developing the
instrument in exercise 1, you probably made interesting observations and managed to create
unique interactions with Arduino and your surroundings. Tweaking both the physical design and the
code is a good way to learn what you can and want to do programming and electronics. If you made the burglar alarm in exercise
2, you got to apply what you've learned to solve a real problem: how to detect if some
item is not where it's supposed to be. The burglar alarm may seem a bit simple, but
you know, Arduino often does pretty simple things in real applications, too. Arduinos and similar devices often just collect
sensor data, or control lights, alarm bells, heating or air conditioning, or so. And a separate central application takes care
of more complex things. I hope you'll enjoy the next chapter. You'll get to create movement with motors,
soon. Have fun! New Arduino commands, structures and concepts in this chapter
analogRead(pin)
Serial.begin(speed)
Serial.print(value) / Serial.println(value)
analogWrite(pin, value)
map(val, fromLow, fromHigh, toLow, toHigh)
Also quickly introduced in the exercises:
random(min, max)