Skip to content

Instantly share code, notes, and snippets.

@emwdx
Created May 13, 2022 05:35
Show Gist options
  • Save emwdx/d615ee1093c7b6ef973c819d2e1338c6 to your computer and use it in GitHub Desktop.
Save emwdx/d615ee1093c7b6ef973c819d2e1338c6 to your computer and use it in GitHub Desktop.
Circuitpython Morse Code Transmitter
import board
import digitalio
import time
from adafruit_clue import clue
import neopixel
start_time = time.monotonic()
letters = {"A":[1,3],"B":[3,1,1,1],"C":[3,1,3,1],"D":[3,1,1],"E":[1],"F":[3,1,1,1],"G":[3,3,1],"H":[1,1,1,1],"I":[1,1],"J":[1,3,3,3],
"K":[3,1,3],"L":[1,3,1,1],"M":[3,3],"N":[3,1],"O":[3,3,3],"P":[1,3,3,1],"Q":[3,3,1,3],"R":[1,3,1],"S":[1,1,1],"T":[3],"U":[1,1,3],"V":[1,1,1,3],"W":[1,3,3],"X":[3,1,1,3],"Y":[3,1,3,3],"Z":[3,3,1,1]}
UNIT_TIME = 0.02
message = ['A','U','T','O','M','A','T','I','O','N']
while True:
current_time = time.monotonic()
for letter in message:
pulse_widths = letters.get(letter)
for interval in pulse_widths:
clue.white_leds = True
time.sleep(interval*UNIT_TIME)
#clue.play_tone(880,interval*UNIT_TIME)
clue.white_leds = False
time.sleep(UNIT_TIME)
time.sleep(5*UNIT_TIME)
time.sleep(7*UNIT_TIME)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment