Project Goal: Implement a two-step verification system in the MSP430G2 Launchpad
ID: 2084947 • Letter: P
Question
Project Goal: Implement a two-step verification system in the MSP430G2 Launchpad Micro-Controller using C LANGUAGE
PROGRAM SPECIFICATIONS:
TWO PASSWORDS NEED TO BE PROGRAMMED INTO THE MSP430G2 DEVICE
PASSWORD 1 = 123
PASSWORD 2 = 321
One switch (let's call it 'KB' switch), a 'reset' switch, and two LED's (RED and GREEN) have been provided on-board for quick development on this micro-controller.
The 'KB' switch should simulate a one-key keyboard for entering the passwords.
The Reset switch will be used for resetting the errors and resetting the red LED when it shows a failure.
When the device is ready to be used, both the RED and GREEN LED should be BLINKING simultaneously.
If the first password passed (first password matches programmed password), the RED LED should be turned off while the GREEN LED remains BLINKING.
If BOTH passwords PASSED, the RED LED should be OFF, and the GREEN LED should be ON (NOT BLINKING).
if a password FAILS, the RED LED should be ON (NOT BLINKING), and the GREEN LED should be OFF. (the RESET SWITCH would need to be used to reset the RED LED).
How to Enter a Password:
To Enter a digit 'n' (0-9), Press the SWITCH assigned to 'KB', 'n' times. (To enter the number '3', press 'KB' 3 times, wait one second, then enter the next 'n' digit.
If the password is CORRECT, just the GREEN LED should blink.
If the password is WRONG, the RED LED should LIGHT ON.
Resetting:
Press the RESET BUTTON one time to go back to the beginning of the PROGRAM.
PLEASE ANSWER IN COMPLETE C CODE
Explanation / Answer
C program:
================
#include <msp430.h>
int main(void)
{
WDTCTL = WDTPW | WDTHOLD; // stop watchdog timer
P1DIR |= 0x41; // Set P1.3 to input direction,P1.0 and P1.6 to output
int state =1;
int pass1[]={1,2,3};
int pass2[]={3,2,1};
while(1){
if(P1IN&0x08) //reading switch KB on P1.3
P1OUT ^= 0x41; // setting P1.0 and P1.6 ON and OFF
}
return 0;
}
===========================
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.