Question

In: Electrical Engineering

Using energia software Write a program for your MSP430 board to will perform the following three...

Using energia software

Write a program for your MSP430 board to will perform the following three tasks: 1. Input: Take a character string as user input through the serial interface. 2. Processing: Convert the entire string to lower case, and 3. Output: Return the processed string to serial output, which will be displayed on your computer monitor. Example: If the input character string is, “Here I am”, the output should be, “here i am”. For serial input and output purpose, you should use the serial monitor feature of the Energia. Note: After completing your homework, make a video of your work with verbal explanations. Make sure your face is seen in the video. If your LaunchPad or Serial Monitor is not responsive when the TA comes to check your homework, show the TA your video.

Solutions

Expert Solution


char* serialString()
{
static char str[21]; // For strings of max length=20
if (!Serial.available()) return NULL;
delay(64); // wait for all characters to arrive
memset(str,0,sizeof(str)); // clear str
byte count=0;
while (Serial.available())
{
    char c=Serial.read();
    if (c>=32 && count<sizeof(str)-1)
    {
      str[count]=c;
      count++;
    }
}
str[count]='\0'; // make it a zero terminated string
return str;
}

void setup() {
Serial.begin(9600);
}

void loop()
{
static boolean needPrompt=true;
String userInput;
if (needPrompt)
{
    Serial.print("Please enter inputs and press enter at the end:\n");
    needPrompt=false;
}
userInput= serialString();
if (userInput!=NULL)
{
    Serial.print("You entered: ");
    Serial.println(userInput);
    Serial.println();
    userInput.toLowerCase();
    Serial.print("You Lower case String: ");
    Serial.println(userInput);
    Serial.println();
    needPrompt=true;
}
}


Related Solutions

Write an assembly program for the MSP430 to calculate the number of zeros and ones in...
Write an assembly program for the MSP430 to calculate the number of zeros and ones in an array. If the number of zeros is more than the number of ones, the red LED(connected to P1.0 on the MSP430 launchpad) will turn on. Otherwise, the green LED (connected to P1.6 on the MSP430 launchpad) will turn on.
Write an MSP430 assembly language program that implements the following algorithm: a macro called "vdot" that...
Write an MSP430 assembly language program that implements the following algorithm: a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as “arrays” (following the “C” language convention), of 3 elements. the macro should receive 2 pointers to the first element of each vector and return the result in R13. I have another file where I save my vectors called, "vars.c" here I save: int a[] = { 14, 65, 9} int b[] =...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called 'numadd' that sums up all the numeric characters present in a phrase ("string" that follows the "C" language convention). By For example, if the phrase is "Today is the 28th of month 9", the subroutine must perform the following sum: 2 + 8 + 9 = 19. The subroutine must receive the address of the first character of the corresponding phrase in the "stack", and return...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that...
Write an MSP430 assembly language program that implements the following algorithm: a subroutine, called ‘numadd’ that sums up all the numeric characters present in a sentence (“string” that follows the “C” language convention). For example, if the phrase is "Today is the 21st of month 5", the subroutine must perform the following sum: 2 + 1 + 5 = 8. The subroutine must receive the address of the first character of the corresponding phrase in the " stack ”, and...
Program Description Write and test a MASM program to perform the following tasks: Display your name...
Program Description Write and test a MASM program to perform the following tasks: Display your name and program title on the output screen. Display instructions for the user. Prompt the user to enter three numbers (A, B, C) in descending order. Calculate and display the sum and differences: (A+B, A-B, A+C, A-C, B+C, B-C, A+B+C). Display a closing message. Program Requirements The program must be fully documented and laid out according to the CS271 Style Guide. This includes a complete...
Write an 8086 assembler program (using the emulator) that will perform the following calculations. All values...
Write an 8086 assembler program (using the emulator) that will perform the following calculations. All values below are decimals. You must attach Screenshot of emu8086 showing the different register values at the end of the execution A printed copy of your code (screenshot is OK) a) (6 -4) * 20 - (9 + 1)            Place the answer in the AX register b) 1000 - 4 * (3 *32)             Place the answer in the AX register
C++ ^ ^ Write a menu driven program to perform following operations using a map container...
C++ ^ ^ Write a menu driven program to perform following operations using a map container that stores the information about USA Population (In Million). @@@Menu@@@ 1. Add Information 2. Display Information 3. Update Information 4. Erase Information 5. Clear Information For example, Suppose the map initially contains following information (Use emplace() function to store the information) 2010, 309.33 2011, 311.58 2012, 313.87 2015, 320.74 2016, 323.07 The program should produce the desired output when a valid input is provided,...
Write an MSP430 assembly language program that implements the following 2 algorithms: 2) a macro called...
Write an MSP430 assembly language program that implements the following 2 algorithms: 2) a macro called "vdot" that calculates the "dot product" of two vectors "a" and "b", implemented as “arrays” (following the “C” language convention), of 3 elements. the macro should receive 2 pointers to the first element of each vector and return the result in R13.
Description: Write and test a MASM program to perform the following tasks: 1. Display your name...
Description: Write and test a MASM program to perform the following tasks: 1. Display your name and program title on the output screen. 2. Display instructions for the user. 3. Prompt the user to enter two numbers. 4. Calculate the sum, difference, product, (integer) quotient and remainder of the numbers. 5. Display a terminating message. Requirements: 1. The main procedure must be divided into sections:  introduction  get the data  calculate the required values  display the results...
Write a program to perform the following two tasks: 1. The program will accept a string...
Write a program to perform the following two tasks: 1. The program will accept a string as input in which all of the words are run together, but the first character of each word is uppercase. Convert the string to a string in which the words are separated by spaces and only the first word starts with an uppercase letter. For example, the string "StopAndSmellTheRose" would be converted to "Stop and smell the rose". Display the result string. 2. Then...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT