Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help me with this problem. I am trying to show two digits on 7 segment di

ID: 3870708 • Letter: P

Question

Please help me with this problem. I am trying to show two digits on 7 segment display. For example if I press the keypad 1 2, the 7 segment display will show both number 1 and 2. If I press 3, the 7 segment will show 2 and 3. Only showing the last two number. My code isn't working. Please help me to fix the code so it can show two digits at the time.

void read(void) {

char leftSide = 'n';
char rightSide = 'n';
char next = readKeyPad();
  
while(1) {
if(rightSide == next || next == 'n'){
printChar (rightSide, Right);
delay(FRAME_PERIOD);
}


else {
  
printChar(next, Right);
delay(FRAME_PERIOD);
printChar(rightSide, Left);
delay(FRAME_PERIOD);
leftSide = rightSide;

rightSide = next;
  
}
  
next = readKeyPad();
}
}

Explanation / Answer

void read(void) {
char leftSide = 'n';
char rightSide = 'n';
char next = readKeyPad();
  
while(1) {
if(rightSide == 'n'){
printChar (next, Right);
delay(FRAME_PERIOD);
rightSide = next;
}

else {
  
printChar(next, Right);
delay(FRAME_PERIOD);
printChar(rightSide, Left);
delay(FRAME_PERIOD);
leftSide = rightSide;

rightSide = next;
  
}
  
next = readKeyPad();
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote