Question: fix this code for MSP 4 3 0 FR 6 9 8 9 to create some kind of character and put the character on A
fix this code for MSP FR to create some kind of character and put the character on A If the left button S is pressed, the
character moves space to the left. If the right button S is pressed, the character moves space to
the right. If the left button is pressed, and the character is in the A position, then the red light should
go on and the character doesnt move. If the right button is pressed, and the character is in the A
position, then the green light should go on and the character doesnt move.
#include
#define SEC xA
#define posB
#define posB
#define posB
#define posB
#define posB
#define posB
#define RED x
#define GREEN x
#define buttonx
#define buttonx
const unsigned int lcdnumxFCxxDBxFxxB;
int currentPosition posB;
void initGPIO
PDIR RED GREEN;
PREN button button;
POUT button button;
void MoveCharacterLeft
if currentPosition posB
currentPosition;
delaycycles; Delay for debouncing
else
POUT RED;
void MoveCharacterRight
if currentPosition posB
currentPosition;
delaycycles; Delay for debouncing
else
POUT GREEN;
void displayCharacter
Update LCD with the character's position
LCDMEMposBcurrentPosition posB lcdnumcurrentPosition : x;
LCDMEMposBcurrentPosition posB lcdnumcurrentPosition : x;
LCDMEMposBcurrentPosition posB lcdnumcurrentPosition : x;
LCDMEMposBcurrentPosition posB lcdnumcurrentPosition : x;
LCDMEMposBcurrentPosition posB lcdnumcurrentPosition : x;
LCDMEMposBcurrentPosition posB lcdnumcurrentPosition : x;
int mainvoid
WDTCTL WDTPW WDTHOLD;
Initialize LCD segments
LCDCPCTLxFFFF;
LCDCPCTLxFCF;
LCDCPCTLxFFF;
LCDCCTL LCDDIV LCDPRE LCDMUX LCDLP;
LCDCVCTL VLCD VLCDREF LCDCPEN;
LCDCCPCTL LCDCPCLKSYNC;
LCDCMEMCTL LCDCLRM;
LCDCCTL LCDON;
PMCTL & ~LOCKLPM;
initGPIO;
while
if PIN & button
MoveCharacterLeft;
MoveCharacterLeft; move the character twice to prevent fast scrolling
POUT & ~RED; Turn off red LED
if PIN & button
MoveCharacterRight;
MoveCharacterRight; move the character twice to prevent fast scrolling
POUT & ~GREEN; Turn off green LED
displayCharacter;
return ;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
