-
Hardware-only solution
11/07/2021 at 16:26 • 0 commentsJohn suggested an alternate solution that requires no changes to the software and no extra MCU pinL Precharge the LEDs by just connecting a fairly large-valued resistor from Vcc to the common line. I tried it out with a couple of 20k resistors and it works! Awesome!
Updated schematic:
-
Software-only solution
11/07/2021 at 16:19 • 0 commentsPaul suggested an alternate solution, namely to turn off LEDs by setting them to high impedance instead of 0V. That way the tiny LED capacitances have no way to charge and thus no ghosting. I tried it and it works! Awesome "zero extra components" solution, fixing it in software.
Here's the relevant change to the sketch that does just that:
// turn off all LEDs by turning them to HiZ pinMode(A0, INPUT); pinMode(A1, INPUT); pinMode(A2, INPUT); pinMode(A3, INPUT); pinMode(A4, INPUT); pinMode(A5, INPUT); // Turn on required LEDs if (mask[pattern] & 0x01) { pinMode(A0, OUTPUT); digitalWrite(A0, HIGH); } if (mask[pattern] & 0x02) { pinMode(A1, OUTPUT); digitalWrite(A1, HIGH); } if (mask[pattern] & 0x04) { pinMode(A2, OUTPUT); digitalWrite(A2, HIGH); } if (mask[pattern] & 0x08) { pinMode(A3, OUTPUT); digitalWrite(A3, HIGH); } if (mask[pattern] & 0x10) { pinMode(A4, OUTPUT); digitalWrite(A4, HIGH); } if (mask[pattern] & 0x20) { pinMode(A5, OUTPUT); digitalWrite(A5, HIGH); }