Hello, I am working at a project and I need the following function to work with common cathode displays.
Please find attached the schematic and the code. I already modified the necessary lines of the code, but when temperature is below 100 degrees, then it shows me the leading zero, and I need to eliminate that zero.
The display is formed by 3 digits with common cathode, with the cathodes driven by NPN transistors.
void show(int value) {
int digits_array[] = {};
boolean empty_most_significant = true;
for (int z = max_digits - 1; z >= 0; z--) //Cycle through each digit
{
digits_array[z] = value / pow(10, z); //We now take each digit from the number
if (digits_array[z] != 0 ) empty_most_significant = false; //Do not display leading zeros
value = value - digits_array[z] * pow(10, z);
if (z == current_digit)
{
if (!empty_most_significant || z == 0) { //Check to see that we do not have leading zeros and display the current digit
PORTD = digits[digits_array[z]]; //Remove ~ for common cathode
}
else
{
PORTD = B11111111;
}
digitalWrite(digit_common_pins[z], HIGH);//Change to HIGH for common cathode
} else {
digitalWrite(digit_common_pins[z], LOW);//Change to LOW for common cathode
}
}
current_digit--;
if (current_digit < 0)
{
current_digit = max_digits; //Start over
}
}



