Click here to access the Canvas page with the repository for this assignment.

In this module you will incorporate non-blocking 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. However, rather than sending it back all at once as in Assignment 4, you should send each dot, dash, and space to Java as you blink the LED for it (see below).
Update your C code to have the Arduino blink an LED for the given Morse code
(and send each dot or dash back to Java as you do). You will
have to process each character of that string 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 character by using array-like notation. For example, this
would print each character in a string one-at-a-time:
String words = "Hello World!";
for(int i=0;i<words.length();i++) {
Serial.print(words[i]);
}
However, you may not use a for or while loop in this assignment to accomplish timing!
If we were to incorporate delta timing behavior into the above for loop,
the code would be considered blocking because program control would never leave
the loop while you were waiting for it to be time to blink your light on or off.
Instead, you must find a way to use the repetitive nature of the Arduino’s loop()
function to accomplish the same thing. Hint: you can use a global variable to iterate
over an array at appropriate times.
., 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 blink the code for
A, which is .-, and then the code for B, which is -.... The LED should
be off for three units between the final element of A and the first element
of B to mark the end of a character.Here are two visualizations showing the full encoding of OH HELLO:
Time: 12345678901234567890123456789012345678901234567890123456789012345678901234567
Message: O---------- H------ H------ E L-------- L-------- O----------
Signal: HHHLHHHLHHHLLLHLHLHLHLLLLLLLHLHLHLHLLLHLLLHLHHHLHLHLLLHLHHHLHLHLLLHHHLHHHLHHH
^ ^ ^ ^ ^
dash | dot | |
element gap word gap character gap
| Character | Complete Morse Code | Each Element | LED On Time | LED Off Time |
|---|---|---|---|---|
| O | --- |
- (1st -) |
3 | 1 |
| ” | - (2nd -) |
3 | 1 | |
| ” | - (3rd -) |
3 | 1 | |
| (between characters) | 2 (total of 3 including above) | |||
| H | .... |
. (1st) |
1 | 1 |
| ” | . (2nd) |
1 | 1 | |
| ” | . (3rd) |
1 | 1 | |
| ” | . (4th) |
1 | 1 | |
| (between characters) | 2 (total of 3 including above) | |||
| ` ` (space) | 4 (total of 7 including above) | |||
| H | .... |
. (1st) |
1 | 1 |
| ” | . (2nd) |
1 | 1 | |
| ” | . (3rd) |
1 | 1 | |
| ” | . (4th) |
1 | 1 | |
| (between characters) | 2 (total of 3 including above) | |||
| E | . |
. |
1 | 1 |
| (between characters) | 2 (total of 3 including above) | |||
| L | .-.. |
. |
1 | 1 |
| ” | - |
3 | 1 | |
| ” | . |
1 | 1 | |
| ” | . |
1 | 1 | |
| (between characters) | 2 (total of 3 including above) | |||
| L | .-.. |
. |
1 | 1 |
| ” | - |
3 | 1 | |
| ” | . |
1 | 1 | |
| ” | . |
1 | 1 | |
| (between characters) | 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() or blocking loops allowed).

The following video shows a brief demo of the expected timing:

Verify that you have completed the following files:
MorseCoder/
MorseCoder.inoMorseCodes.cppMorseCodes.hcommunication/
SerialComm.javaCommit 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.
morseEncode()'.' '-' and ' ' to your Java program over the Serial port as your code does the appropriate blinking.debug to display the outgoing and incoming data as the LED is blinking.
Generated at 2026-10-09 20:51:54 +0000.
Page written by Julia Vogl, Bill Siever, Jeremy Goldstein, Evan Simkowitz, and James Orr.