The figure shows the activity on pin
13 while the program is running.
The pin starts in
LOW
state and doesn t
output any current. We use
to set it to
HIGH
and let it output 5 volts
for 500 milliseconds. Finally, we set it back to
repeat the whole process.
That s it! You ve created your first physical computing project. You ve written
some code, and it makes the world brighter. Your very own digital version of
17
"fiat lux."
Admittedly, the status LED doesn t look spectacular. In
Binary Dice, on page
39, we ll attach "real" LEDs to the Arduino.
You ll need the theory and skills you ve learned in this chapter for nearly every
Arduino project. In the next chapter, you ll see how to gain more control over
LEDs, and you ll learn how to benefit from more advanced features of the
Arduino IDE.
What If It Doesn't Work?
Choosing the wrong serial port or Arduino type is the most common mistake
when doing the first experiments with an Arduino. If you get an error message
such as "Serial port already in use" when uploading a sketch, check whether
you have chosen the right serial port from the
get messages such as "Problem uploading to board" or "Programmer is not
responding," check whether you have chosen the right Arduino board from
the
Tools > Board
menu.
Your Arduino programs, like all programs, will contain bugs. The compiler
will detect typos and syntax errors.
errors nicely, on page 22
we called
pinMod
, and because the compiler didn t find a function with that
name, it stopped with an error message. The Arduino IDE highlights the line,
showing the error with a yellow background, and prints a helpful error mes-
sage.
Other bugs might be more subtle, and sometimes you have to carefully study
your code and use some plain old debugging techniques. (In
17.
http://en.wikipedia.org/wiki/Fiat_lux
5 V
digitalWrite
0 V
LOW
Figure 6, The Arduino IDE explains syntax
shows a typical error message. Instead of
www.it-ebooks.info
What If It Doesn't Work?
for 500 milliseconds and
Chapter 3, Building
Tools > Serial Port
menu. If you
pinMode
Debug It! Find,
21
,
report erratum
discuss
Need help?
Do you have a question about the Arduino Uno and is the answer not in the manual?