loading

The following information is a single lesson in a larger project. Find more great projects here.

Return to Previous Lesson: Manual Morse Code Machine

Lesson Overview:

Now we're going to make an machine for automatically sending morse code!

Step 1: What Is Morse Code?

Before the days of the telephone it was incredibly hard for people to communicate with others over long distances. Once the telegraph was invented by Samuel Morse, it allowed people to communicate with each other remotely. The telegraph was only capable of sending long and short pulses of a tone; each letter or number was represented by a combination of long and short pulses. Additionally, after each letter, number or word there is a slightly longer wait to signify the end of the character.

Morse Code is now a dead language; the last commercial transmission of Morse Code in the US was on July 12, 1999. Samuel Morse's telegraph and code paved the way for the telephone and other important radio equipment.

Look below for a chart of all the letters and numbers in Morse Code.

  1. Continue to the next step.

Step 2: SOS

In this step we will learn how to program our arduino to emit Morse code of our choosing. To do this we will have to program our arduino; which we can do in the code editor. For this exercise you will need three commands also known as functions which are:

short_pulse(); //This is the function for making short pulseslong_pulse(); //This is the function for making long pulsesdelay(int); //This is a function for inserting delays between functions

  1. Start by pressing the 'Code Editor' button in the top right hand corner.
  2. Insert two new lines after line 16 in your code. On each of the new lines you will insert the function 'short_pulse();' . Each time you insert this function your arduino will make a short pulse.

    HINT: Unable to edit your program? You may need to stop your simulation first.

  3. Insert a new line after line 18 in your code. On the new line type in the function 'delay(letter_pause);' . This will add a slight delay after it finishes transmitting a letter. Congratulations, you have just made the letter 'S' in Morse Code.
  4. Insert 3 more lines after line 19 in your program. On each of the new lines add the function 'long_pulse();' .
  5. Insert a new line after line 22. On this line type the function 'delay(letter_pause);' . Once you have completed the last instruction, you have made the letters 'SO' in Morse Code.
  6. Insert 3 more lines after line 23. On each of the new lines add the function 'short_pulse();'
  7. Insert a new line after line 26. On this line add the function 'delay(word_pause);' . Congratulations, you have just made the word 'SOS' in Morse Code.
  8. Now lets test it to make sure it works. In the top left corner of the code editor window, press 'Upload & Run'.

    HINT: If your program won't compile, make sure you typed everything correctly and that there is a semicolon (;) after each function. Also, make sure that all of the code you have written is in between the curly brackets of void loop.

  9. Continue to the next step.

Step 3: Making a Function

In this step you will learn how to create functions in Arduino. Functions allow you to to execute large blocks of code by typing a single line of code. The function we will create will make the Morse Code Machine transmit the message "SOS".

  1. Start by pressing the 'Code Editor' button in the top right hand corner.

    HINT: The Code Editor button is to the left of the Components button.

  2. Scroll to the bottom of your program which should be line 43 and insert a new line. On line 44 type 'void SOS() {' There are many different types of functions. The type of function we are using in this activity is a void function; this function does not return any information when we call it. The function will just execute the code you tell it to and then go away.
  3. We are going to cut and paste our code from void loop () and move it to void SOS (). Highlight all of the code on lines 16 through 27 and cut it by pressing 'Ctrl + X' or 'Command + X'
  4. Insert a new line after line 33. Paste your code by pressing 'Ctrl + V' or 'Command + V'.

    HINT: Make sure that you don't accidentally put in a semicolon at the end of your new function.

  5. Insert a new line after line 45. Add a closing curly bracket or '}'. Curly brackets tell the computer when blocks of code start and finish. An opening bracket or '{' means that the block of code has started and closing bracket or "}" means the block of code is finished.
  6. On line 16 we will call our newly created function by typing 'SOS();'
  7. Press the 'Upload & Run' button. Your machine should be blinking the message SOS.
  8. Continue to the next step.

In the next lesson you will learn to send your own messages!

Next Lesson:Make Your Own Message

<p>Dead language? Since when? Try listening on the shortwave bands before spouting such rot. Morse is still used since it can get through in situations that speech never can.</p>
morse code is not a dead language. more people use today than at any other time. many thousands of ameture radio (ham radio) operator use fill the airwaves with dits and dahs of morse code as they use it to communicate with others around the world
<p>Thank you for saying that uspatriota, indeed!</p><p>AF6YS</p>

About This Instructable

391views

7favorites

License:

More by circuits:Introduction Arduino Project 15: Hacking Buttons Arduino Project 14: Tweak the Arduino Logo 
Add instructable to: