Click here to access the Canvas page with the repository for this assignment.
In this module you will incorporate delta timing into the Morse code assignment from Module 4. You will add an LED to your Arduino which will turn on for short (and slightly longer) amounts of time corresponding to dots and dashes in the Morse encoding of messages sent from Java.
By the end of this assignment you should have a better understanding of how delta timing works and how it can be used. In addition, you will practice: iterating through arrays, working with ASCII characters, and considering the logic required to properly implement non-blocking (i.e., delta) timing.
Begin by importing your Java code and MorseCoder.ino from Assignment 4 into their appropriate spots in Assignment 5. All functionality from Assignment 4 should still be in this assignment. Java will still send a user-input message to Arduino to be encoded. The Arduino will then still encode the message and send it back to Java.
Update your C code to have the Arduino blink an LED for the given Morse code. You will
have to process each character of the Morse code separately. For example,
the morseEncode()
function will return a
String. You will have
to loop through the returned string, retrieve each character, and use the
character to turn on an LED for the appropriate amount of time. You can
access an individual letter by using array-like notation. For example, this
would print each letter in a string one-at-a-time:
String words = "Hello World!";
for(int i=0;i<words.length();i++) {
Serial.print(words[i]);
}
.
, turns the LED on for 1 unit-
, turns the LED on for 3 unitsA
is .-
. The LED needs to be off
for 1 unit between when it is on for the .
and then on again for the -
.AB
you would have to blink the code for A
, which is
._
, and the code for B
, which is -...
. The LED should be off for
three units of time between the final symbol of A
and the start of B
to
indicate the end of a letter.Here are two visualizations showing the full encoding of OH HELLO
:
Time: 1234567890123456789012345678901234567890123456789012345678901234567890123 Message: O---------- H---- H---- E L-------- L-------- O---------- Signal: HHHLHHHLHHHLLLHLHLHLLLLLLLHLHLHLLLHLLLHLHHHLHLHLLLHLHHHLHLHLLLHHHLHHHLHHH ^ ^ ^ ^ ^ dash | dot | | symbol space word space letter space
Character | Complete Morse Code | Each Symbol | LED On Time | LED Off Time |
---|---|---|---|---|
O | --- |
- (1st - ) |
3 | 1 |
” | - (2nd - ) |
3 | 1 | |
” | - (3rd - ) |
3 | 1 | |
(between letter) | 2 (total of 3 including above) | |||
H | .... |
. (1st) |
1 | 1 |
” | . (2nd) |
1 | 1 | |
” | . (3rd) |
1 | 1 | |
(between letter) | 2 (total of 3 including above) | |||
` ` (space) | 4 (total of 7 including above) | |||
H | ... |
. (1st) |
1 | 1 |
” | . (2nd) |
1 | 1 | |
” | . (3rd) |
1 | 1 | |
(between letter) | 2 (total of 3 including above) | |||
E | . |
. |
1 | 1 |
(between letter) | 2 (total of 3 including above) | |||
L | .-.. |
. |
1 | 1 |
” | - |
3 | 1 | |
” | . |
1 | 1 | |
” | . |
1 | 1 | |
(between letter) | 2 (total of 3 including above) | |||
L | .-.. |
. |
1 | 1 |
” | - |
3 | 1 | |
” | . |
1 | 1 | |
” | . |
1 | 1 | |
(between letter) | 2 (total of 3 including above) | |||
O | --- |
- (1st - ) |
3 | 1 |
” | - (2nd - ) |
3 | 1 | |
” | - (3rd - ) |
3 | 1 |
Although you may initially use delay()
timing to get going with the assignment, when you’re done you should only be using delta timing (i.e., NO delay()
allowed).
The following video shows a brief demo of the expected timing:
Verify that you have completed the following files:
- `MorseCoder/`
- `MorseCoder.ino`
- `MorseCodes.cpp`
- `MorseCodes.h`
- `communication/`
- `SerialComm.java`
Commit all your code. Do not ask to be checked out by a TA until after you have made certain that your work is committed. Failing to do this may result in you losing points on your assignment.
moreseEncode()
'.'
'-'
and ' '
to your Java program over the Serial portdebug
to display the outgoing and incoming data
Generated at 2022-07-20 19:49:20 +0000.
Page written by Julia Vogl, Bill Siever, Jeremy Goldstein, Evan Simkowitz, and James Orr.