The first command creates a file named
Telegraph.zip
, and the second one creates
Telegraph.tar.gz
. Both formats are widespread, and it’s best to offer them both
for download.
Although you have to perform a lot of manual file operations, it’s still easy to
create an Arduino library. So, there’s no excuse: whenever you think you’ve
built something cool, make it publicly available.
Note that the structure for library projects has slightly changed in the Arduino
IDE 1.5.x and later.
6
The biggest change is that all library source files (
tele-
graph.h
and
telegraph.cpp
, in our case) now have to be stored in a separate folder
named
src
. The new specification is backwards compatible—that is, old libraries
will still work in the new IDE.
Until now, our projects have communicated with the outside world using
LEDs (output) and pushbuttons (input). In the next chapter, you’ll learn how
to work with more sophisticated input devices, such as ultrasonic sensors.
You’ll also learn how to visualize data that an Arduino sends to programs
running on your computer.
What If It Doesn’t Work?
The Arduino IDE has a strong opinion on naming files and directories, and
it was built for creating sketches, not libraries. So, you need to perform a few
manual file operations to get everything into the right place. In the figure on
the preceding page, you can see the final directory layout. If you have more
than one version of the Arduino IDE installed, make sure you’re using the
correct
libraries
folder.
Remember that you have to restart the IDE often. Whenever you change one
of the files belonging to your library, restart the IDE.
If syntax coloring doesn’t work, make sure your keywords file is actually
named
keywords.txt
. Double-check whether you have separated all objects and
type specifiers by a tab character. Restart your IDE!
Exercises
• Morse code not only supports letters and digits, but it also defines symbols
such as commas. Improve the
Telegraph
class so that it understands all
characters of the Morse code.
6.
https://github.com/arduino/Arduino/wiki/Arduino-IDE-1.5:-Library-specification
report erratum • discuss
What If It Doesn’t Work? • 73
www.it-ebooks.info