Arduino External (wired up) LED & S.O.S
Hardware
For this assignment you must wire up LED with your breadboard. Use your teacher’s example and/or ask for help.
- Wire up an LED to Pin 13 through your breadboard.
- Remember that you must have a resistor in the circuit and that the long pin on the LED points to the power supply (short pin towards ground)
Software - The Ship is Going Down!! Send the S-O-S
Note: There is a final 20% version of this assignment that requires a substantial rewrite of the code.
- Create a new sketch called Arduino_SOS OR use the Blink Example code and save as Arduino_SOS
- Using the Blink example code as a starting point, write the code to send S O S in morse code. Morse code is described here: http://www.omniglot.com/writing/morsecode.htm
Dash = 0.5 second
Dot = 0.25 seconds
Pause for a half second between dashes and dots and one full second between letters
- After the second S, pause for 2 full seconds with the light off
- Hint: For each dash or dot, you will likely need FOUR lines of code:
Turn on the led
Wait while it is on
Turn off the led
Pause before turning it on again
Demo your assignment to your teacher. Do NOT dismantle the wiring afterwards as you may need it for the next activity.
Final 20% - Using functions and arrays
- Create a function called morse() that takes in a letter as a parameter (as a String or a char).
- Inside, it only needs to handle the letters S, O, C & T plus a pause.
- If any of these letters are passed in, it will flash the proper morse code as described above.
- If any other letter is passed in, the LED will flash very quickly 3 times before moving on.
- In the global variable area, create an array that holds the letters S, O, S, pause.
- String letters[] = {"S","O", "S",”pause”};
- In the loop() function, use a for loop to call the morse function for each letter. (see code below)
morse(i);
}
- Test the code by changing the array to include both valid and invalid letters.