Morse Code LED Arduino Mega 2560
My group for the embedded systems class project is with michael radford and myself. I will be going over the overall design schematic and requirements for the first project called morse code. Mike will then show a live demonstration of the morse code and give an overview of the code. The overall goal of this project is to create a program that will take in a string and convert it into morse code using an led. The software design will be using a round robin approach for this project. We used an arduino mega 2560, a breadboard one led, and a 220 ohm resistor here is a flow diagram of our program. The program will first wait for an input over the serial port. If it receives a carriage return, it will then exit the program if it receives a string ending in a new line. Well, then, take the string and convert it into morse code outputting it using an led. It will then wait for another string and repeat this over and over again until a carriage return is received next ill show you the schematic, diagram or breadboard diagram, as sometimes referred. So this is how we had it wired up our breadboard. We had a 220 ohm resistor one led and our arduino mega um next ill be going over the requirements. So we had five total requirements. The application shall use an led application, shall utilize round robin design. The application shall display user type strings on an led using the inter international morse crow standard.
We provided a link to the morse code standard below the application. Also shall wait for a sentinel character, a new line before transforming that string into mars code, the application shall exit when it receives a carriage return. The carriage return can also be known as a sentinel character. Next, mike will show you a live demonstration and an overview of the code hi everyone, my name, is mike radford and im working with christina hellberg ill, be presenting the demonstration part of our first project. Well start with the setup, as you can see in the camera here in the bottom right, we use an arduino mega 2560 and we use these two wires connected to ground and one to pin 7, which goes through a 220 ohm resistor into an led on our Breadboard, so you can see in the background here, we use the arduino sketch ide to write rc plus plus code and use its flashing functionality to program the board over a serial line. Um. So do a quick walk through the code. Arduino sketch starts by using this setup function. In our case it just initializes the serial line and the led pin. Then it goes into this loop function here, um. So, in our case, the loop waits for serial input and when it gets some, it reads all the available characters um if it sees a sentinel character, which you can see as a carriage return uh that exits the program. But if it doesnt it gets a valid string ending in a new line um then it actually moves into the morse code logic as per the project requirements.
As you can see here, it calls this string to morse function. If we take a look at that right here, it steps, through the string character by character, converts each character to an intermediate, more string of dots and dashes, which you can see in this big switch statement here. This intermediate string is kind of nice. In case you ever want to extend this, and maybe um emit a sound from a speaker or something like that: its not dependent on the hardware here. So you take this intermediate string and pass it to this flash more string function, which once again goes character by character, flashes, the led appropriately that being 100 milliseconds for a dot and 300 milliseconds for a dash. Once you finish with that, you go back to the loop logic and wait for more input from the serial line, so ill. Do a quick demonstration just to show how this works ill, open up the serial, monitor and fire up a string. You can see the led flashes that test string do another. One once again see the led flash according to the string, and once that finishes we can send a character, turn the sentinel character and you can see it terminates.