This project needs to debug using Code Composer Studio. the Microcontroller bein
ID: 3717685 • Letter: T
Question
This project needs to debug using Code Composer Studio. the Microcontroller being used is an MSP430G2553
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’.
The link below shows the microcontroller flashing the message "SOS", which stands for "Save Our Ship" and is a universal distress signal. https:/lyoutu belo6tGNO IXMk In the video, the LED flashes the message "SOS". It shows three quick flashes (letter S), followed by three long flashes (letter O), then three short flashes (letter S). After a pause, the message is flashed again, in an infinite loop. The green light indicates the message is about to restart. Message S: dot-dot-dot 0: dash-dash-dash S: dot -dot-dot These 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) First, translate the two messages at the links below. What strings did you get? Message 1: httpsyoutu.be/AWtsLwcOTw4Explanation / Answer
ANS:-
Given that,
program:-
const int BUTTON = 5; //use button on board
const int LED = 14; //use red led on board
int ledState = LOW; //current ledState
int buttonState; //current buttonState
int lastButtonState = LOW; //previous buttonState
long time = 0; //last time switch is pressed
long debounce = 50; //debounce time
void setup()
{
//set I/O pins
pinMode(BUTTON, INPUT_PULLUP);
pinMode(LED, OUTPUT);
}
void loop()
{
int buttonState = digitalRead (BUTTON); //is switch press?
//when button is press & (previous & current state is different) & (previous - current time > debounce)
if (buttonState == HIGH && lastButtonState == LOW && millis() - time > debounce)
{
if (ledState == HIGH) //when LED IS ON
{
ledState = LOW; //turn LED OFF
}
else //when LED is OFF
{
ledState = HIGH; //turn it ON
}
time = millis(); //save time after releasing the button
}
digitalWrite (LED, ledState); //output LED
lastButtonState = buttonState; //save the previous buttonState to current buttonState
}
#include <msp430g2553.h>
void main(void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
P1DIR |= BIT6; // Set P1.6 (green LED) to output direction, 1 is output
P1OUT &= ~BIT6; // Set the green LED off
P1DIR &= ~BIT3; // Port 1 P1.3 (push button) as input, 0 is input
P1REN |= BIT3; // Enable Port 1 P1.3 (push button) pull-up resistor
P1OUT |= BIT3; // The button is up
while(1)
{
if( (P1IN & BIT3 ) == 0) // Push button down when bit 3 == 0
{
if ((P1OUT | BIT6) == 0)
{
P1OUT &= ~BIT6;
}
else
{
P1OUT |= BIT6;
}
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.