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 #93 background imageLoading...
Page #93 background image
Blinking LEDs are great, but when we think of Morse code, we usually
think of beeping sounds, so replace the LED with a piezo speaker, which
is cheap and easy to use. The following figure shows how you connect it
to an Arduino. Piezo speakers have a ground pin and a signal pin, so
connect the speakers ground to the Arduinos ground, and connect the
signal pin to Arduino pin 13.
Then replace the
output_symbol
method with the following code:
void Telegraph::output_symbol(const int length) {
const int frequency = 131;
tone(_output_pin, frequency, length);
This sends a square wave to the speaker, and it plays a tone having a
frequency of 131 Hertz. (Look at the example under File > Examples >
02.Digital > toneMelody that comes with the Arduino IDE to learn more
about playing notes with a piezo speaker.)
The Arduino IDE offers an alternative way to handle serial communication.
Have a look at Serial Communication Using Various Languages, on page
255, and rewrite the Morse code library so that it uses the new
serialEvent
function. Also, use
String
objects instead of character arrays.
Improve the librarys design to make it easier to support different output
devices. You could pass some kind of
OutputDevice
object to the
Telegraph
constructor. Then derive a
LedDevice
and a
SpeakerDevice
from
OutputDevice
. It
could look as follows:
class OutputDevice {
public:
virtual void output_symbol(const int length);
};
class Led : public OutputDevice {
Chapter 4. Building a Morse Code Generator Library 74
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