Question: Help me find the solution please!! Program source code: - #include #include #include #include void UART _ Init ( ) { TMOD | = 0
Help me find the solution please!!
Program source code:
#include
#include
#include
#include
void UARTInit
TMOD x; Timer in mode autoreload
THxFD; Set baud rate to for a MHz crystal
SCON x; bit UART, enable receiver
TR; Start timer
char UARTReadChar
whileRI; Wait until character is received
RI ; Reset receive interrupt flag
return SBUF; Return received character
void UARTSendCharchar c
SBUF c; Send character via UART
whileTI; Wait until character is sent
TI ; Reset transmit interrupt flag
void UARTSendStringchar str
whilestr
UARTSendCharstr; Send character via UART
str; Move to next character in string
void main
char input;
char c;
int i len ;
char password "kuastha";
UARTInit;
while
int i len ;
UARTSendStringEnter password:
;
do
c UARTReadChar; Read character from UART
ifc r Ignore carriage returns
continue;
ifc b Handle backspaces
ifi
i;
UARTSendCharc;
UARTSendChar;
UARTSendCharc;
continue;
inputi c; Store character in string
UARTSendCharc; Echo character back to terminal
i;
whilec ; Stop when null terminator is received
inputi; Replace newline with null terminator
UARTSendStringr
You entered: ;
UARTSendStringinput;
Secured password checking algorithm
len i ;
TR; End Timer
iflen strlenpassword Check length of input string
Do something if password is incorrect
Px;
TR;
UARTSendStringr
Incorrect password length :r
;
return ;
else
fori ; i len; i Compare characters one by one
ifinputi passwordi
Do something if password is incorrect
TR;
UARTSendStringr
Incorrect password found!r
;
break;
return ;
if i len All characters match
TR;
UARTSendStringr
Password accepted!r
;
Do something if password is correct
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
