Robotics-II-Circuit-Python

Circuit Python tutorials in Robotics II

View the Project on GitHub MrPrattASH/Robotics-II-Circuit-Python

Table of Contents

S.O.S. Blinking LED

Now that you can make an LED blink simply, try this challenge. (modified from this tutorial)

Morse Code

Morse code is a system for sending messages as a sequence of ON and OFF signals with predefined spaces in between.

image

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.

Your Challenge

Write code inside your “while True” loop to blink the message SOS. We need to make our LED:

  1. blink 3 dots (S)
  2. wait for 3 units (between letters)
  3. blink 3 dashes (O)
  4. wait for 3 units (between letters)
  5. blink 3 dots (S)
  6. wait for 7 units (between words)

tips:

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)

Extension

Now that you can S.0.S, try out other words to send!