I'm living in an LLC. It's a new program that offers Lafayette students a chance to learn about a topic in themed housing. My house, Monroe@, is technology themed, which means I can do all sorts of fun things in the name of learning!
One of our projects for the year will be automating the house's door. We all carry HID RFID fobs for access to campus buildings, and want to enable the door to respond to those phobs. All we need is a reader to read our cards, a servo to turn the deadbolt back for a second, and some brains. I have servos already, so I went to the internet and bought an Arduino Leonardo for brains, and a HID brand reader for reading.
Guess what came yesturday? The arduino! I know that the things are bashed for being overused by hobbists, but they're so much easier to use than microcontrollers in C.
I wanted to play with it, but didn't have any parts. There are a pile of leftover LED's at the house, but nothing else. No buttons, no fancy inputs, no resistors.
First, I made sure everything was working by loading a blink program to the arduino, and admiring it. There's something empowering about making an LED blink.
Blinking's cool, I suppose, but the Arduino is so much more powerful. I decided to write a morse code flasher. Pulled morse code tables from the internet, wrote methods for dits and dahs, and made some code that would read information from the computer over serial. The libraries made everything fairly easy, but debugging is hard when the device doesn't provide any information as to internal state.
The final program listens for serial input from the computer. When a line's transmitted, it saves the line as a string, then interates over that line, pushing the morse code for each character to the LED. If any more serial input is detected, it dead-ends and starts flashing the new sequence.
Checking for serial data introduces some strange pauses into the program, but hey! Autonomous Morse code in an afternoon!