Question

msp430 launchpad 2553 C programming Write a program for the microcontroller that flashes the Morse code pattern of a string. The Morse code is a system used to transmit characters and numbers through...

msp430 launchpad 2553 C programming

Write a program for the microcontroller that flashes the Morse code pattern of a string. The Morse code is

a system used to transmit characters and numbers through light or sound signals. Each character is

mapped to a series of ‘dots’ and ‘dashes’ as shown below. For example, the letter A is (dot-dash), the letter

B is (dash-dot-dot-dot) etc. To show a Morse letter on the microcontroller, the LED blinks for a short

duration to represent a ‘dot’ or for a long duration to represent a ‘dash’.

here are the timing rules. The unit should be a small duration that you choose.

The length of a dot is one unit (1x)

A dash is three units (3x)

The space between a dot and a dash within a letter is one unit (1x)

The space between letters within a word is three units (3x)

The space between words is seven units (7x)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

#include<stdio.h>
#include<c type.h>
#include<string.h>
int main()
{
char str[25],str1[100];
printf ("Enter the String: ");
scanf ("%s", str);
int j=0;
int i=0;
for(i=0;i<=strlen(str);i++)
{
switch(to upper(str[i]))
{
case 'A':
str1[j++]='.';
str1[j]='-';
break;
case 'B':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case 'C':
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case 'D':
str1[j++]='-';
str1[j++]='.';
str1[j]='.';
break;
case 'E':
str1[j]='.';
break;
case 'F':
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case 'G':
str1[j++]='-';
str1[j++]='-';
str1[j]='.';
break;
case 'H':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case 'I':
str1[j++]='.';
str1[j]='.';
break;
case 'J':
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j]='-';
break;
case 'K':
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case 'L':
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j]='.';
break;
case 'M':
str1[j++]='-';
str1[j]='-';
break;
case 'N':
str1[j++]='-';
str1[j]='.';
break;
case 'O':
str1[j++]='-';
str1[j++]='-';
str1[j]='-';
break;
case 'P':
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j]='.';
break;
case 'Q':
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case 'R':
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case 'S':
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case 'T':
str1[j]='-';
break;
case 'U':
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case 'V':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case 'W':
str1[j++]='.';
str1[j++]='-';
str1[j]='-';
break;
case 'X':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case 'y':
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j]='-';
break;
case 'Z':
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='.';
break;
case '0':
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j]='-';
break;
case '1':
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j]='-';
break;
case '2':
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j]='-';
break;
case '3':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='-';
break;
case '4':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case '5':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case '6':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case '7':
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case '8':
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='.';
break;
case '9':
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j]='.';
break;
case '.':
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case ',':
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='-';
break;
case ':':
str1[j++]='-';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case '?':
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='.';
break;
case '-':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case ';':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case '(':
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case ')':
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case ']':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j]='-';
break;
case '[':
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case '}':
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case '{':
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j]='-';
break;
case '"':
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case '+':
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case '/':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case '%':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case '&':
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='.';
break;
case '$':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case '*':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='-';
str1[j]='-';
break;
case '^':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case '#':
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
case '@':
str1[j++]='.';
str1[j++]='-';
str1[j++]='-';
str1[j++]='.';
str1[j++]='-';
str1[j]='.';
break;
case '=':
str1[j++]='-';
str1[j++]='.';
str1[j++]='.';
str1[j++]='.';
str1[j]='-';
break;
}
j++;
}
str1[j-1]='\0';
printf ("%s", str1);
return 0;
}

Add a comment
Know the answer?
Add Answer to:
msp430 launchpad 2553 C programming Write a program for the microcontroller that flashes the Morse code pattern of a string. The Morse code is a system used to transmit characters and numbers through...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Program Description: A C# app is to be created to produce Morse code. The Morse code...

    Program Description: A C# app is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

  • Program Description: A Java program is to be created to produce Morse code. The Morse code...

    Program Description: A Java program is to be created to produce Morse code. The Morse code assigns a series of dots and dashes to each letter of the alphabet, each digit, and a few special characters (such as period, comma, colon, and semicolon). In sound-oriented systems, the dot represents a short sound and the dash represents a long sound. Separation between words is indicated by a space, or, quite simply, the absence of a dot or dash. In a sound-oriented...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT