Before the invention of the two-way radio, messages were transmitted using Morse Code, which used patterns of flashing lights or audio beeps to represent different characters in the alphabet. For example, the "beeeeeeep beeeeeeep beeeeeep beep beep beeeeeeeep beeeeeeeep beeeeeeeeep" sound that some cell phones make when an SMS is received is actually the Morse Code for the letters "S", "M" and "S"! Similarly, the series of beeps that the TV station plays before their news broadcasts is also a Morse Code message.
This assignment will not involve any mechanical tinkering on the part of your robot, or moving about for the jacket wearers. All that you will need to do is to use the light sensor (jacket groups, your i*CATch main board has a light sensor onboard) to receive an encoded message and to print out the decoded string onto the monitor.
Detailed specifications are as follows:
This is by far the most complex problem that you have encountered so far. Therefore, we're giving you some help:
Since this program is fairly complex, we're going to give you the general algorithm to solve this program:
That's the general algorithm. It's just a suggestion, you can try your hand at coming up with your own algorithm if you want.
In the algorithm, there are several places where the program is supposed to wait for the light to turn on. You can do this using a while True loop:
while True:
if the light sensor detects light
break
Process the light signal
Something very similar can be used to wait for the light to turn off.
To decide whether a flash of light is a dot or a dash, you will need to time it to see how long it has been on for.
You will need to make use of the timing capabilities of the computer. Python gives us a time module that has the time.clock() function that you will find useful. time.clock() returns a floating point number that represents the time elapsed (in seconds) since the program started running.
Therefore, suppose that you need to time the length of operation A. You can use this general algorithm:
startTime = time.clock() do Operation A elapsedTime = (time.clock() - startTime)
Note: time.clock() does not work as well on Mac or UNIX machines as it does on Windows machines. But don't worry -- on those operating systems, you can use time.time() instead, which will do something similar. Just remember that your demo will be on the lab machines, which run Windows, so change it back to time.clock() and test it out before you hand in your program!
Your program should be called MorseCode.py.
Together with your program, we're going to request that you hand in a brief report describing your work in English. This report should not be more than one page long, and it should include the following parts:
Your program will be evaluated in two ways: through your code, and also through a demonstration. Therefore, you will need to hand in your program to WebCT, as well as to demonstrate it to the TA.
The deadline for handing in the code is 07:00, Thursday December 3, 2009. No late submissions are allowed. The person in the group with the smallest studentID should hand in the code. If we get multiple submissions in the group, we'll just pick the one with the smallest studentID and ignore the rest.
For the demonstration, you are to sign up for a time slot. During the demonstration, you will first demo your program running to your TA. He will watch your program do its task, and then will ask you some questions about your program. He might also choose to do a "wire-pull test" -- which is, the TA will make some changes to your code when you're not looking. Then you will have to debug your program in front of him.
Bear in mind that the TA can ask anybody in your group to do the demo, or to debug the program. He/she also has the right to ask the rest of the groupmates to leave the room while the program is being demoed. Therefore, everybody needs to be present for the demo.