Skip to content

ComputationalExpression/assignment-morse-code-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Morse Code

Dots and Dashes lab header

Date
20 February 2026 Assigned
13 March 2026 Due
Progress Grade

We're finally at the promised moment: the Morse code alphabet. Behold it, in its full glory:

Morse code alphabet

From the source of all (mis)information, Wikipedia:

The American artist Samuel Morse, the American physicist Joseph Henry, and mechanical engineer Alfred Vail developed an electrical telegraph system. The simple "on or off" nature of its signals made it desirable to find a method of transmitting natural language using only electrical pulses and the silence between them. Around 1837, Morse therefore developed such a method, an early forerunner to the modern International Morse code.

The Morse system for telegraphy was designed to make indentations on a paper tape when electric currents were received. Morse's original telegraph receiver used a mechanical clockwork to move a paper tape. When an electrical current was received, an electromagnet engaged an armature that pushed a stylus onto the moving paper tape, making an indentation on the tape. When the current was interrupted, a spring retracted the stylus and that portion of the moving tape remained unmarked.

Learning Objectives

This assignment addresses the following course learning objective(s):

  1. Apply Python programming fundamentals to execute and explain computer code that implements interactive, novel solutions to a variety of computable problems.
  2. Implement code consistent with industry-standard practices using professional-grade integrated development environments (IDEs), command-line tools, and version control systems.
  3. Analyze and suggest revisions to existing Python language code to add functionality or repair defects.
  4. Evaluate the practical and ethical implications of writing computer code and discuss the contexts, perceived effects, and impacts exerted on and by computer code as a cultural force or artifact.
  5. Design, describe, and implement original projects incorporating industry-standard practices and Python language fundamentals.

Pinout Diagram

Note

Students may already have this system assembled from a previous lab.

Pinout Diagram

The above graphic is a pinout diagram: a description of how to wire a physical computing project. Match the above diagram with the following components:

  • push button
  • Raspberry Pi Pico
  • 2 wires
  • breadboard

Important

The above writing is critical to the code. We address specific parts during our programs. Make sure it matches. If you have questions, ask a TL or the instructor!

Summary of the problem

We're only implementing A-Z, and 0-9 with a few other signals. Namely, the signals we need to add in [src/morse.py]:

Signal name Signal pattern Meaning
AR .-.-. End of message
SK ...-..- End of transmission
" " ....... Space character (" ")

Important

In order to run the program in this lab, you'll need to do the following when you've made the appropriate changes:

uv run mpremote cp src/morse.py :

If you need to re-upload the file, run the above command again!

Implementing hardware

The hardware (the Raspberry Pi Pico) relies on some fundamental structures:

  • Pins
    • Pin.IN
    • Pin.OUT
  • sleep

For this lab, all we care about is that there is a button and an LED. The following code implements the subsequent topics:

from machine import Pin
from time import sleep

def main():
    btn = Pin(16, Pin.IN, Pin.PULL_UP)
    led = Pin("LED", Pin.OUT)
    while True:
        if btn.value() == 0:
            led.on()
            sleep(.15)
        led.off()
"Debouncing"

Buttons often need a bit of a delay to guarantee that we only capture one press at a time. To do this, we implement "debouncing," a strategy where we sleep our running program for a short, but sufficient, amount of time during which to ignore further button presses.

Pins

Pins represent physical pins on the Raspberry Pi Pico device which can be either inputs or outputs. Our button is an input: Pin(16, Pin.IN); our LED is an on-board output: Pin("LED", Pin.OUT).

As a general rule, 0 indicates a press, and 1 indicates the button is not being pressed.

Evaluation

Note

To grade this lab, use the uv run gatorgrade command.

Labs in this course are each worth 5 points. You are awarded different levels of points using the following rubric:

Component Value
Programming 2
Code Review 2
Writing 1
Total 5

Programming

Your programming will be evaluated on the following characteristics:

  • Program produces the correct output
  • translate_signal takes in a list and produces correct output
  • if receiving SK, the program prints >: ENDING CONVERSATION
  • if receiving AR, the program prints the message
  • for short and long signal sequences, add the resolved alphanumeric character to a message variable
  • to submit a character for translation in translate_signal, the user must have paused for 2 seconds
  • words must be separated by a space (.......)
  • the program must be able to print WHAT HATH GOD WROUGHT (the first telegraph morse code message ever sent)

Expected output

In response to a precise sequence of short and long presses (denoted as . and -, respectively, for this lab), you should be able to create sequences of letters and words. There is no punctuation in the specification, so it's not necessary.

Code review

Either a Technical Leader TL or the instructor can perform a code review with you. This must be done before the due date for the assignment. You may accomplish this during a lab session, TL office hours, or during the instructor's office hours. Successful completion of this review (and an accompanying successful outcome) will earn points toward the code review portion of the assignment.

Writing

Students are expected to finish a summary document. This is a Markdown file containing questions. All questions must be answered fully. Typically, this means a word count is assessed.

For this assignment, the minimum required word count is 150.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages