Circuit Python tutorials in Robotics II
View the Project on GitHub MrPrattASH/Robotics-II-Circuit-Python
Now that you can make an LED blink simply, try this challenge. (modified from this tutorial)
Morse code is a system for sending messages as a sequence of ON and OFF signals with predefined spaces in between.
A key for international Morse code Attribution: Rhey T. Snodgrass & Victor F. Camp, 1922, Public domain, via Wikimedia Commons
Characters in Morse code are represented by a series of dots and dashes, which we will use to determine the length of time our LED turns on for.
Write code inside your “while True” loop to blink the message SOS. We need to make our LED:
Option #1
UNIT = 1.0
# unit time of 1s each. This is a LONG processing code
UNIT = 0.2
# unit time of 0.1s each. This is a MUCH FASTER processing code.
#Dot
led.value = True # turn on
time.sleep(UNIT) # sleep 3 "units"
led.value = False # turn off
time.sleep(UNIT)
#Dash
led.value = True # turn on
time.sleep(UNIT*3) # sleep 3 "units"
led.value = False # turn off
time.sleep(UNIT)
Now that you can S.0.S, try out other words to send!