|It turns out that working with GPIO on the RPi is simple. As you can see in the photo to the right I don't have the ribbon cable adapter for the RPi so I used five jumper cables. Three of them are for the pins that I will use for driving the LED colors (red, green, and orange = blue since I didn't have a blue cable). The ground is the black jumper. The extra red jumper is used to measure the power on the RPi 5v bus (more here).|
For now I only have this setup for testing. I am going to put the LED inside a ping pong ball and stick it on a mast on the stern of the 'bot across from the compass, ideally with a reset switch for the Arduino as things are getting crowded.
The code to drive this RGB LED as a Morse Code signaler is here. I don't anticipate sending any other message other than SOS but I got carried away. This sample code also illustrates the use of option parsing in Python but I will talk to that later. Some of the key snippets from this code are here:
# Initialize the GPIO module and our three pins
# Do the actual blinking
def blink(r, g, b, duration):
global RED, GREEN, BLUE
# Reset the pins we used
Obviously this is the most simple example possible but it shows the initialization, writing to a pin, and the all important cleanup.
BTW, you need to run this under sudo to access the GPIO. There is a discussion of alternatives here.
Almost all the code related to the Morse Code functionality came from a post created by Stephen Chappell on Thu, 12 Jan 2012 (MIT)