The Creative Team here at Engage has worked hard on the Fourbell application over the last few weeks, and from that project has come the idea to create a physical doorbell, wired via Ethernet, to play a unique MP3 anytime someone checks into the office here at Engage. For this project one of our team members has been leveraging the power of Arduino boards to create a simple solution. Watching a jumble of wires and connectors all come together on a tiny board intrigued my interest, and I was quickly convinced to buy a starter kit at the RadioShack down the street (there are dozens of designs and additions available via online vendors).
The $60 starter kit comes with everything you need to get started with the Arduino platform. Contents include: Arduino Uno, USB cable, 9V battery pack w/DC plug (batteries not included of course), a clear breadboard, a whole bunch of wires, LEDs, a photoresistor, and 30 resistors of differing strengths. There are also a plethora of guides and starting tutorials available online.
To get started programming your Arduino you will need to download the Arduino Environment software. Once this is installed, connect the Arduino board to your computer via USB. You will then have to install the drivers for your board (they can be found in the Arduino Environment folder). Then, launch the Arduino application and you are ready to go! Detailed step-by-step instructions can be found HERE.
After testing the basic Blink program which the setup guide runs you through, I decided that I wanted to see what else I could do with the board, and I really wanted to leverage some of the goodies that came in the starter kit. I thought about what I could do with just some LEDs and decided that it would be fun to write a program (and configure the board) so that a user could enter text and then have it displayed in **Morse Code by an LED. I did not use any guides or tutorials to write the code as I decided doing it myself would be the best way to learn.
My first big challenge was deciding how I wanted to encode the Morse timings to be displayed. I wanted to create a system that was easy to program and expand, and ended up going with maybe the simplest solution: manually initialing a two-dimensional array. I chose to map each character’s timing stored in the array to that character’s corresponding ASCII value. While this does mean there is a significant amount of empty/wasted space in the array, it makes future expansion of the character timings extremely simple.
The next issue I ran into was deciding on what data structure to read the user input into. Because there is no way to predict how much input the user will enter I wanted to try and avoid having to constantly resize arrays. Creating a simple linked-list node implementation solved this easily, and also works well with the Arduino Serial.read() which reads in a single byte (or in our case a single character) at a time.
Once I had all the user input entered in my linked-list I simply traversed through the list and found the ASCII value of each character. If the character was a valid character (it has a timing sequence in the array) I then used a simple for loop to go through the timing array for that character and display it via the LED.
The last step was wiring the breadboard. This was fairly straightforward, connecting a wire to ground and another wire to the pin of your choosing (I used pin 13) and then connecting both to two sequential number lines on the breadboard. Then put your LED across those two lines (make sure it is in the right way – shorter end on the ground) and you are all set.
Maybe the most unique problem I encountered during this experience was getting the timings right (a higher timing increases the delay the program uses to keep the LED on). I initially had them so low that either the board was processing them too fast for the LED, or the LED was blinking too fast for my eye to detect. I originally thought that the board was displaying no data at all and that I had logic error until I finally tested the timings and realized they needed to be higher.
Please enjoy the video below for a quick demonstration. The code for this project can be found HERE under Morse_Code_LED. Check back in the future for further iterations of the project.
The next part of the project will be to connect a sensor and read the light values from the LED back into the system to translate the Morse into plain text. From there, adding a button to manually light the LED will be a good addition, and finally, connecting a speaker and configuring sounds for a fully functioning Morse Code machine.
*Please note, the following is done on a PC running Windows 7. Steps may differ on other platforms.
** There is a plaque honoring the sending of the first Morse Code message, “What hath God wrought” in 1844 on the outer wall of the mini-rotunda by the Old Supreme Court Chamber in the U.S. Capitol Building.Leave a comment