Programming Homework Help. San Diego State University Generic Morse Code Transmission Worksheet
Write a code in C that outputs any arbitrary string by blinking the LED in Morse code using the AVR Xplained Mini board
The method you choose must output any standard null-terminated string containing characters A-Z or 0-9 in Morse code on the board’s LED
The program is recommended to have different functions for dot, dash, and space
The functions can be called based on the desired output. Using functions makes it simple to design multiple outputs, as you simply call on what you need, whenever
A child function, called from main( ) should output your Name and ID number in Morse code, using a method that will work for any arbitrary string constant•
Let 1 unit of time for this program be 200ms
A dot is equivalent one unit (200ms)
A dash is equivalent to three units (600ms)
The space between the dot/dash units of the same letter is one unit (200ms)
The space between different letters is three units (600ms)
The space between words is seven units (1400ms)
example
A simple function to determine the letter to translate into Morse code and call the right functions for blinking pattern:
if (s[i] == ‘A’ || s[i] == ‘a’)
{
dot(); dash(); spc();
}
example
#define F_CPU 16000000UL // 16MHz clock from the debug processor
#include <avr/io.h>
#include <util/delay.h>
int main(void)
{
/* Replace with your application code */
DDRB |= (1<<DDB5); //0x20 (hex) // Set port bit B5 in data direction register to 1: an OUTput
while(1)
{
PORTB |= (1<<PORTB5); //Set port bit B5 to 1 to turn on the LED
_delay_ms(100); //delay 100ms
PORTB &= ~(1<<PORTB5); //Clear port bit B5 to 0 to turn off the LED
_delay_ms(100);
}
}
C code with comments and .c file required
Programming Homework Help