EasyManuals Logo

Arduino uno User Manual

Arduino uno
311 pages
To Next Page IconTo Next Page
To Next Page IconTo Next Page
To Previous Page IconTo Previous Page
To Previous Page IconTo Previous Page
Page #83 background imageLoading...
Page #83 background image
In the first line, we create a new
Telegraph
object that communicates on pin
13 and emits dits that are 200 milliseconds long. Then we emit the message
Hello, world! as Morse code. This way, we are able to send whatever message
we want, and we can change easily the pin and the length of a dit.
Now that we have defined the interface, we will implement it.
Fleshing Out the Morse Code Generators Interface
Declaring interfaces is important, but its as important to implement them.
Create a new tab and enter the filename
telegraph.cpp
.
This is the right place to explain why weve used
TelegraphLibrary
and not
Telegraph
as the sketch name, even though itd be a more natural choice. The reason
is that the Arduino IDE turns every sketch (ending with
.ino
) into a C++ file
(ending with
.cpp
). For a sketch named
Telegraph.ino
it generates a C++ file named
Telegraph.cpp
. In a case-insensitive file system, this conflicts with a file named
telegraph.cpp
, and it leads to some strange error messages.
Enter the following code now in the newly created tab:
TelegraphLibrary/telegraph.cpp
#include <ctype.h>
#include <Arduino.h>
#include "telegraph.h"
const char* LETTERS[] = {
".-", "-...", "-.-.", "-..", ".", // A-E
"..-.", "--.", "....", "..", ".---", // F-J
"-.-", ".-..", "--", "-.", "---", // K-O
".--.", "--.-", ".-.", "...", "-", // P-T
"..-", "...-", ".--", "-..-", "-.--", // U-Y
"--.." // Z
};
const char* DIGITS[] = {
"-----", ".----", "..---", "...--", // 0-3
"....-", ".....", "-....", "--...", // 4-7
"---..", "----." // 8-9
};
Like most C++ programs, ours imports some libraries first. Because we need
functions such as
toupper
later, we include
ctype.h
, and we have to include
telegraph.h
to make our class declaration and its corresponding function decla-
rations available. But what is
Arduino.h
good for?
Until now we havent thought about where constants such as
HIGH
,
LOW
, or
OUTPUT
came from. They are defined in several header files that come with the
Chapter 4. Building a Morse Code Generator Library 64
report erratum discuss
www.it-ebooks.info

Table of Contents

Other manuals for Arduino uno

Questions and Answers:

Question and Answer IconNeed help?

Do you have a question about the Arduino uno and is the answer not in the manual?

Arduino uno Specifications

General IconGeneral
Form factorArduino
CertificationRoHS, FC, CE
Processor model-
Processor frequency- MHz
Microcontroller modelATmega328
Microcontroller frequency16 MHz
DC input voltage7-12 V
Operating voltage5 V
DC current per I/O pin40 mA
Flash memory0.032 MB
Maximum internal memory- GB
SRAM (Static Random Access Memory)2 KB
EEPROM (Electrically Erasable Programmable Read-Only Memory)1 KB
Wi-FiNo
Number of analog I/O pins6
Number of digital I/O pins14
Weight and Dimensions IconWeight and Dimensions
Board dimensions53.4 x 68.6 mm

Related product manuals