From charlesreid1

(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...")
 
No edit summary
Line 1: Line 1:
==Installing the Arduinomorse Library==
This page covers the use of a morse code library to operate a blinking LED on the Arduino Micro.


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


==An Arduinomorse Sketch==
First, let's talk about how to get some morse code libraries on the Arduino.


Now we can rewrite our sketch to use the arduinomorse library. NOTE THAT IT MUST BE LOWERCASE:
[[Morse Code Arduino]]


<source lang="c">
We basically have two options:
#define PIN_STATUS 12
* Use the [[Arduinomorse Library]]
#include <morse.h>
* Use the [[Morse Library]]
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();
}
 
</source>
 
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.
I'll show an example of using both, so you can get an idea of the advantages/disadvantages of different libraries. Morse code is a good example of how a relatively simple task can quickly become befuddling to implement, but how there are many tasks that already have libraries.


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 Arduinomorse Library==


==The Circuit==
To use the Arudinomorse library, see the [[Arduinomorse Library]] and [[Arduino Installing Libraries]] for installation instructions for getting libraries into the Arduino Development Environment.


===Breadboard Diagram===
==The Morse Library==


Here is a breadboard layout using Fritzing:
To use the Morse library, see the [[Morse Library]] page for installation.


[[Image:bb_BlinkSpeaker.png|500px]]


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:
=Arduino Sketch Code=


[[Image:photo_BlinkSpeaker2.jpg|500px]]
The following sketches show how to implement a simple blink circuit with morse code.


==Arduinomorse Speaker Sketch Code==
==Arduinomorse Blink==


Finally, we can use the Arduinomorse library to generate our morse code tones, by switching from a <code>LEDMorseSender</code> object to a <code>SpeakerMorseSender</code> object:
Now we can rewrite our sketch to use the arduinomorse library. NOTE THAT THE MESSAGE WE SEND MUST BE LOWERCASE:


<source lang="c">
<source lang="c">
#define PIN_STATUS 12
#define PIN_STATUS 12
#include <morse.h>
#include <morse.h>
//LEDMorseSender sender(PIN_STATUS);
LEDMorseSender sender(PIN_STATUS);
SpeakerMorseSender sender(PIN_STATUS);
//SpeakerMorseSender sender(PIN_STATUS);


void setup() {
void setup() {
Line 71: Line 50:
</source>
</source>


==Upload and Go==
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.
 
==Morse Blink==
 
The morse library works differently, by giving the user finer-grained control at the character-by-character level, but it follows the same basic idea.
 
<source lang="c">
Morse morse();
morse.send(s);
morse.send(o);
morse.send(s);
</source>
 
 


Once you upload the sketch, your piezo speaker should start sending out morse code.
[[Category:Arduino]]

Revision as of 15:23, 19 July 2015

This page covers the use of a morse code library to operate a blinking LED on the Arduino Micro.

Morse Code on the Arduino

First, let's talk about how to get some morse code libraries on the Arduino.

Morse Code Arduino

We basically have two options:

I'll show an example of using both, so you can get an idea of the advantages/disadvantages of different libraries. Morse code is a good example of how a relatively simple task can quickly become befuddling to implement, but how there are many tasks that already have libraries.

The Arduinomorse Library

To use the Arudinomorse library, see the Arduinomorse Library and Arduino Installing Libraries for installation instructions for getting libraries into the Arduino Development Environment.

The Morse Library

To use the Morse library, see the Morse Library page for installation.



Arduino Sketch Code

The following sketches show how to implement a simple blink circuit with morse code.

Arduinomorse Blink

Now we can rewrite our sketch to use the arduinomorse library. NOTE THAT THE MESSAGE WE SEND 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.

Morse Blink

The morse library works differently, by giving the user finer-grained control at the character-by-character level, but it follows the same basic idea.

Morse morse();
morse.send(s);
morse.send(o);
morse.send(s);