Sorry, I am still a beginner in C programming but I have some experience in C++ programming. I have encountered this code shown below and I have no idea how it works. How does it convert the values to BCD values and why is it necessary to be shown on the LCD display? Thank you for everyone who is helping.....
unsigned int ui_decimal[5] ={ 0 };
//extract 5 single digit from ui_number
ui_decimal[4] = ui_number/10000; // obtain the largest single digit, digit4
ui_decimal[3] = ui_number%10000; // obtain the remainder
ui_decimal[2] = ui_decimal[3]%1000;
ui_decimal[3] = ui_decimal[3]/1000; // obtain the 2nd largest single digit, digit3
ui_decimal[1] = ui_decimal[2]%100;
ui_decimal[2] = ui_decimal[2]/100; // obtain the 3rd largest single digit, digit2
ui_decimal[0] = ui_decimal[1]%10; // obtain the smallest single digit, digit0
ui_decimal[1] = ui_decimal[1]/10; // obtain the 4th largest single digit, digit1
if (uc_digit > 5) uc_digit = 5; // limit to 5 digits only
for( ; uc_digit > 0; uc_digit--)
{
lcd_putchar(ui_decimal[uc_digit - 1] + 0x30);
}
}