Skip to content

Instantly share code, notes, and snippets.

@t5r7
Created June 25, 2019 21:40
Show Gist options
  • Save t5r7/a3ff67770924e5a661eb98d2a41b8c44 to your computer and use it in GitHub Desktop.
Save t5r7/a3ff67770924e5a661eb98d2a41b8c44 to your computer and use it in GitHub Desktop.
Keyboard Lock Light/Beeper Morse Code
import os, time
import morse_talk as mtalk
dotLen = 0.08
print('Keyboard Lock LED Morse Code')
code = raw_input('Morse Code: ')
codeSplit = list(code)
if codeSplit[0] != '.' or codeSplit[0] != '-':
codeSplit = list(mtalk.encode(code))
for character in codeSplit:
print(character)
# if character == ' ':
# time.sleep(dotLen * 7)
# else:
time.sleep(dotLen)
if character == '.':
os.system('xdotool key Num_Lock')
os.system('beep -d 0 -D 0 -f 300 -l ' + str(0.2 * 1000))
os.system('xdotool key Num_Lock')
if character == '-':
os.system('xdotool key Caps_Lock')
os.system('beep -d 0 -D 0 -f 500 -l ' + str((0.2 * 2) * 1000))
os.system('xdotool key Caps_Lock')
pip install morse-talk
apt install xdotool
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment