Question: I need help adding a buzzer to my Morse Code but I am not sure where exactly to add it or how to add it
I need help adding a buzzer to my Morse Code but I am not sure where exactly to add it or how to add it to make a short beep for every '.' we see and a longer beep for every '-' we see. I am using the MSP432 in code composer. P6.0 is my buzzer pin.
void main(void) { WDT_A->CTL = WDT_A_CTL_PW | WDT_A_CTL_HOLD; // stop watchdog timer
//Buzzer Pin P6->DIR |= BIT0; P6->OUT &= ~BIT0;
int ch; while(1) {
ch = getc(stdin); toMorse(ch); }
return; }
void toMorse(char c) {
int m; int i;
char *morse_letter[] = { ".-", "-...", "-.-.", "-..", ".", "..-.", "--.", "....", "..", ".---", "-.-", ".-..", "--", "-.", "---", ".--.", "--.-", ".-.", "...", "-", "..-", "...-", ".--", "-..-", "-.--", "--.." }; char *morse_digit[] = { "-----", ".----", "..---", "...--", "....-", ".....", "-....", "--...", "---..", "----." };
if( isalpha(c) ) //Checks if whether character is an alphabet or not { c = toupper(c); // Morse is not case sensitive m = c - 'A'; printf("%s ",morse_letter[m]);
} else if( isdigit(c) ) //Checks whether character is a digit { m = c - '0'; printf("%s ",morse_digit[m]);
} else if( c==' ' || c==' ' ) { putchar(' '); } else printf("Wrong Input"); return; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
