From charlesreid1

Revision as of 15:12, 19 July 2015 by Admin (talk | contribs) (Created page with "==Installing the Arduinomorse Library== On to the next part of the project: getting Arduino to run Morse Code! See the Arduinomorse Library page. ==An Arduinomorse Sketc...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Installing the Arduinomorse Library

On to the next part of the project: getting Arduino to run Morse Code! See the Arduinomorse Library page.

An Arduinomorse Sketch

Now we can rewrite our sketch to use the arduinomorse library. NOTE THAT IT MUST BE LOWERCASE:

#define PIN_STATUS 12
#include <morse.h>
LEDMorseSender sender(PIN_STATUS);
//SpeakerMorseSender sender(PIN_STATUS);

void setup() {
    sender.setup();
    sender.setWPM(20);
    sender.setMessage(String("v v v de kc7dbu ar"));
    sender.startSending();
}
void loop() {
    sender.continueSending();
}

How does this bad boy work? Well, the morse library contains encodings of letters into dots and dashes. These dots and dashes are then encoded into voltage signals that are dits or dashes. When the voltage is applied, the LED lights up.

Blink Speaker

The next part of the project is to connect a speaker in lieu of an LED, so that we can use that same voltage to generate morse code tones from a speaker.

The speaker I used was a 3 - 28 V DC piezoelectric speaker. No resistors were needed, since I was using 5 volts, which was in the range of the speaker.

The Circuit

Breadboard Diagram

Here is a breadboard layout using Fritzing:

Bb BlinkSpeaker.png

As mentioned, pretty straightforward: we're powering the positive and negative buses with the red and black cables, connected to the Arduino's 12 pin and ground, respectively. We then route power from the positive bus to the piezo speaker's red wire, then the voltage passes through the speaker (generating sound), and the remaining voltage passes through the black wire to ground.

Breadboard Photo

Here is a photo of the above circuit, constructed on a breadboard:

Photo BlinkSpeaker2.jpg

Arduinomorse Speaker Sketch Code

Finally, we can use the Arduinomorse library to generate our morse code tones, by switching from a LEDMorseSender object to a SpeakerMorseSender object:

#define PIN_STATUS 12
#include <morse.h>
//LEDMorseSender sender(PIN_STATUS);
SpeakerMorseSender sender(PIN_STATUS);

void setup() {
    sender.setup();
    sender.setWPM(20);
    sender.setMessage(String("v v v de kc7dbu ar"));
    sender.startSending();
}
void loop() {
    sender.continueSending();
}

Upload and Go

Once you upload the sketch, your piezo speaker should start sending out morse code.