skip to main |
skip to sidebar
I did a Fritz breadboard of the Morse Code buzzer - there's nothing complicated about it, just rather messy with all the wires..
A breadboard shield would be nice (so i ought to get on & make one!).
/** Project: functions_MorseCodeBuzzer* Author: Jane-Maree Howard* Date: Monday 22/03/2010* Platform: Arduino 18* Purpose: To demonstrate a Morse code buzzer.* Operation: The buzzer makes only clicking noises so* evidently we will have to make it oscillate,* i.e. buzz. This will need its own routine call.* I expect turning it on-off repeatedly will be enough.* Most of the code has been re-used from MorseCode_MyName,* since it does much the same thing, but with the exception* of a buzzer routine call for every LED flash, since this* what is associated with the sound.*/int pinBlu = 10; // off-board Blue LEDint pinBuzz = 12; // output to buzzerint iBuzz = 12; // 'Buzz' oscillations cycle countint i; // 'Buzz' oscillations counterint dLay = iBuzz*3; // basic delay = 'dot' buzz cyclevoid setup(){ pinMode(pinBlu, OUTPUT); pinMode(pinBuzz, OUTPUT); digitalWrite(pinBlu, LOW); digitalWrite(pinBuzz, LOW);}//end setup()/* This loop makes use of user-defined functions called dot() and dash() which in turn make up the Morse letters e.g. Juliet() Here I spell out my name: 'Jane-Maree Paula Howard'*/void loop(){ delay(7*dLay); // 1.75 sec delay - delay between words delay(7*dLay); // 1.75 sec delay - delay between words delay(7*dLay); // 1.75 sec delay - delay between words Juliet(); //J Alpha(); //A November(); //N Echo(); //E Hyphen(); //- Mike(); //M Alpha(); //A Romeo(); //R Echo(); //E Echo(); //E delay(7*dLay); // 1.75 sec delay - delay between words Papa(); //P Alpha(); //A Uniform(); //U Lima(); //L Alpha(); //A delay(7*dLay); // 1.75 sec delay - delay between words Hotel(); //H Oscar(); //O Whiskey(); //W Alpha(); //A Romeo(); //R Delta(); //D delay(7*dLay); // 1.75 sec delay - delay between words}//end loop() // Main body of program/* Now we define the functions buzz(), dot() & dash() These represent the 'character elements' of each alpha-numeric character. Then we define the Alpha characters in terms of dot() & dash() Note that buzz() is included in dot() & dash() As can be seen above, calling these functions is quite easy. */// buzz() is actually an oscillation routine; frequency ~500Hz void buzz(int j){ for (i=0; i
{
delay(2);
digitalWrite(pinBuzz, HIGH);
delay(1);
digitalWrite(pinBuzz, LOW);
}//for(++)
}//end buzz()
void dot()
{
digitalWrite(pinBlu, HIGH);
buzz(iBuzz);
//delay(dLay); // 250 millisec delay - length of 'character element'
digitalWrite(pinBlu, LOW);
delay(2*dLay); // 500 millisec delay - delay between 'character elements'
}//end dot()
void dash()
{
digitalWrite(pinBlu, HIGH);
buzz(iBuzz*3);
//delay(dLay*3); // 750 millisec delay - length of 'character element'
digitalWrite(pinBlu, LOW);
delay(2*dLay); // 500 millisec delay - delay between 'character elements'
}//end dash()
/* Now we make functions using functions: in this case the Morse alphabet of
various characters; named using the military alpha-word-code - Alpha Bravo etc
*/
//Juliet di-dah-dah-dah
void Juliet()
{
dot();
dash();
dash();
dash();
delay(2*dLay);
}//end juliet()
//Alpha di-dah
void Alpha()
{
dot();
dash();
delay(2*dLay);
}//end Alpha()
//November dah-dit
void November()
{
dash();
dot();
delay(2*dLay);
}//end November()
//Echo dit
void Echo()
{
dot();
delay(2*dLay);
}//end Echo()
//Mike dah-dah
void Mike()
{
dash();
dash();
delay(2*dLay);
}//end Mike()
//Romeo di-dah-dit
void Romeo()
{
dot();
dash();
dot();
delay(2*dLay);
}//end Romeo()
//Hyphen dah-di-di-di-di-dah
void Hyphen()
{
dash();
dot();
dot();
dot();
dot();
dash();
delay(2*dLay);
}//end Hyphen()
//Papa di-dah-dah-dit
void Papa()
{
dot();
dash();
dash();
dot();
delay(2*dLay);
}//end Papa()
//Uniform di-di-dah
void Uniform()
{
dot();
dot();
dash();
delay(2*dLay);
}//end Uniform()
//Lima di-dah-di-dit
void Lima()
{
dot();
dash();
dot();
dot();
delay(2*dLay);
}//end Lima()
//Hotel di-di-di-dit
void Hotel()
{
dot();
dot();
dot();
dot();
delay(2*dLay);
}//end Hotel()
//Oscar dah-dah-dah
void Oscar()
{
dash();
dash();
dash();
delay(2*dLay);
}//end Oscar()
//Whiskey dah-dah-dah
void Whiskey()
{
dot();
dash();
dash();
delay(2*dLay);
}//end Whiskey()
//Delta dah-dit
void Delta()
{
dash();
dot();
dot();
delay(2*dLay);
}//end Delta()
/* end of user-defined functions */
/* * Project: functions_Morse Code - MyName * Author: Jane-Maree Howard * Date: Saturday 20/03/2010 * Platform: Arduino 18 * Purpose: (1)To demonstrate a sketch for flashing Morse code (2)This document explains how to create a library for Arduino. * Operation: It starts with a sketch and explains how to convert its functions into a library. * This allows other people to easily use the code that you've written * and to easily update it as you improve the library. * We start with a sketch that does simple Morse code: * The code is simple & ideal for telegraphy: a sequence of 'dots' & 'dashes' * (or 'dit' & 'dah') encoding alpha-numeric characters, * beginning with 'e'='dit', & 't'='dah' (the most commonly used letters in * English text, & progressing to the less common characters. * Wikipedia gives the 'mark-space' intervals for Morse code as follows: * 1/ A 'dash' is equal to 3 'dots' * 2/ The space between parts of the same letter is equal to 1 'dot' * 3/ The space between two letters is equal to 3 'dots' * 4/ The space between two words is equal to 7 'dots' * Here I spell out my name: Jane-Maree, using two levels of function call*/int pin = 13; //on-board LEDint dLay = 250; //basic delayvoid setup(){ pinMode(pin, OUTPUT);}//end setup()/* This loop makes use of user-defined functions called dot() and dash() which in turn make up the Morse letters e.g. Juliet() Here I spell out my name: 'Jane-Maree'*/void loop(){ Juliet(); //J Alpha(); //A November(); //N Echo(); //E Hyphen(); //- Mike(); //M Alpha(); //A Romeo(); //R Echo(); //E Echo(); //E delay(7*dLay); // 1.75 sec delay - delay between words delay(7*dLay); // 1.75 sec delay - delay between words }//end loop() // Main body of program/* Now we define the functions dot() & dash() These represent the 'character elements' of each alpha-numeric character As can be seen above, calling these functions is quite easy */void dot(){ digitalWrite(pin, HIGH); delay(dLay); // 250 millisec delay - length of 'character element' digitalWrite(pin, LOW); delay(2*dLay); // 500 millisec delay - delay between 'character elements'}//end dot()void dash(){ digitalWrite(pin, HIGH); delay(dLay*3); // 750 millisec delay - length of 'character element' digitalWrite(pin, LOW); delay(2*dLay); // 500 millisec delay - delay between 'character elements'}//end dash()/* Now we make functions using functions: in this case the Morse alphabet of various characters; named using the military alpha-word-code - Alpha Bravo etc*///Juliet di-dah-dah-dahvoid Juliet(){ dot(); dash(); dash(); dash(); delay(2*dLay); }//end juliet()//Alpha di-dahvoid Alpha(){ dot(); dash(); delay(2*dLay);}//end Alpha()//November dah-ditvoid November(){ dash(); dot(); delay(2*dLay);}//end November()//Echo ditvoid Echo(){ dot(); delay(2*dLay);}//end Echo()//Mike dah-dahvoid Mike(){ dash(); dash(); delay(2*dLay);}//end Mike()//Romeo di-dah-ditvoid Romeo(){ dot(); dash(); dot(); delay(2*dLay);}//end Romeo()//Hyphen dah-di-di-di-di-dahvoid Hyphen(){ dash(); dot(); dot(); dot(); dot(); dash(); delay(2*dLay);}//end Hyphen()/* end of user-defined functions */
This little program is found in the tutorial on FUNCTIONS.I've titivated it up a bit/** Project: functions_Morse Code - SOS* Author: Jane-Maree Howard* Date: Thursday 18/03/2010* Platform: Arduino 18* Purpose: (1)To demonstrate a sketch for flashing Morse code (2)This document explains how to create a library for Arduino.* Operation: It starts with a sketch and explains how to convert its functions into a library.* This allows other people to easily use the code that you've written* and to easily update it as you improve the library.* We start with a sketch that does simple Morse code:* Invented by Samuel Morse (back in the day!), this telegraph code was later used for* wireless (radio) telegraphy in conditions where radio-telephony (speech) was unclear* owing to weak signals, radio-interference etc. An operator with a good 'fist' could* transmit 40-50 words per minute (or possibly more). The code is simple & ideal for* telegraphy: a sequence of 'dots' & 'dashes' (or 'dit' & 'dah') encoding alpha-numeric* characters, beginning with 'e'='dit', & 't'='dah' (the most commonly used letters in* English text), & progressing to the less common characters.* Here 'dit-dit-dit dah-dah-dah dit-dit-dit' encodes the international distress call 'SOS'*/int pin = 13; //on-board LEDint dLay = 250; //basic delayvoid setup(){pinMode(pin, OUTPUT);}//end setup()/* This loop makes use of user-defined functions called dot() and dash() */void loop(){dot(); dot(); dot(); // Morse code: . . . = Sdelay(2*dLay); // delay between charactersdash(); dash(); dash(); // Morse code: - - - = Odelay(2*dLay);dot(); dot(); dot(); // Morse code: . . . = Sdelay(2*dLay);delay(12*dLay); // 3 seconds}//end loop() // Main body of program/* Now we define the functions dot() & dash() These represent the 'character elements' of each alpha-numeric character As can be seen above, calling these functions is quite easy */void dot(){digitalWrite(pin, HIGH);delay(dLay); // 250 millisec delay - length of 'character element'digitalWrite(pin, LOW);delay(dLay); // 250 millisec delay - delay between 'character elements'}//end dot()void dash(){digitalWrite(pin, HIGH);delay(dLay*4); // 1 second delay - length of 'character element'digitalWrite(pin, LOW);delay(dLay); // 250 millisec delay - delay between 'character elements'}//end dash()/* end of user-defined functions */This is taken directly (with my own additions) from 'Arduino - LibraryTutorial'