adafruit / Adafruit_Trellis_Library

Arduino library for controlling Adafruit Trellis
45 stars 24 forks source link

LED Ghosting in Trellis #12

Open technoblogy opened 7 years ago

technoblogy commented 7 years ago

Description

The Trellis 4x4 HT16K33 LED/Keypad I2C driver board uses the same ROW lines for multiple keys, but avoids ghosting by including a diode in series with these lines.

For example, the buttons labelled 3 and 4 on the PCB (SW1G$1 and SW1G$2 on the schematic) both connect via R5 to COM2 and COM1 respectively, but have series diodes, avoiding button ghosting.

However, some buttons connect to COM1 or COM2 without diodes, and this causes LED ghosting.

For example, the buttons labelled 1 and 2 on the PCB (SW1G$4 and SW1G$3 on the schematic) connect via R10 and R7 respectively to COM1. Pressing both these buttons simultaneously shorts R7 and R10 together, so if an LED is lit on R7, the one on the same COM line and R10 will also light, and vice-versa.

The same is true of the buttons labelled 5, 6, 7, 9, 13, and 14.

The following program demonstrates this:

#include <Wire.h>
#include "Adafruit_Trellis.h"

Adafruit_Trellis matrix0 = Adafruit_Trellis();

Adafruit_TrellisSet trellis =  Adafruit_TrellisSet(&matrix0);
#define INTPIN A2

void setup() {
  trellis.begin(0x70);  
  trellis.setLED(0);
  trellis.setLED(4);
  trellis.setLED(12);
  trellis.writeDisplay(); 
}

void loop() {}

Demonstration

Run the program. Buttons 1, 5, and 13 light up. Press buttons 1 and 2; button 2 lights up. Press buttons 8 and 9 or 8 and 10; button 9 or 10 lights up. Press buttons 13 and 14; button 14 lights up.

Remedy

The solution is to include a diode in series with every button. This would require an additional 8 diodes. I believe you could then dispense with the diodes in series with the COM1 and COM2 lines, so you actually only need an extra 6 diodes.

I've already assembled the Trellis board I bought, so it would be difficult to test this by cutting tracks and adding diodes, but if you'd like me to test it on a new board I'll be happy to do that.