Hi there
I’ve come into bit of a problem with using the Feather 2040 and the LED Arcade Button 1x4 - STEMMA QT I2C Breakout. The buttons are wired up correctly and im using some basic functionality to make the buttons light up and press a keyboard keys from 1 to 4. However i’m getting a reocurring problem with Switch 4.
Originally I thought the switch on the breakout was faulty and I got a replacement one sent to me, however the problem persists with this new one.
The problem is that the LED and Switch keeps firing off and flickering, i’ve switch the buttons and cables but its the same thing. Now i’m wondering if this is a code problem or a feather problem, i’ve included the code below that its using. if anyone has any insight to the problem it would be a phenomenal help
#include “Keyboard.h”
#include “Adafruit_seesaw.h”
#include <seesaw_neopixel.h>
#define DEFAULT_I2C_ADDR 0x3A
Adafruit_seesaw ss;
bool button18HasBeenPressed = false;
bool button19HasBeenPressed = false;
bool button20HasBeenPressed = false;
bool button2HasBeenPressed = false;
void setup() {
Serial.begin(115200);
if (!ss.begin(DEFAULT_I2C_ADDR)) {
Serial.println(“seesaw not found!”);
while(1);
}
// Setup button pins as input with pullup
for(int i=18; i<=21; i++) {
ss.pinMode(i, INPUT_PULLUP);
}
// Initialize the Keyboard library
Keyboard.begin();
}
void loop() {
// Example: Read Button 1 (Pin 18)
if (!ss.digitalRead(18)) {
if(!button18HasBeenPressed){
button18HasBeenPressed = true;
// Button pressed - set LED 1 (PWM 12) to full brightness
ss.analogWrite(12, 255);
Keyboard.press(‘1’);
}
} else {
button18HasBeenPressed = false;
// Button released - turn off LED 1
ss.analogWrite(12, 0);
Keyboard.releaseAll(); // Releases all keys
}
// Example: Read Button 2 (Pin 19)
if (!ss.digitalRead(19)) {
if(!button19HasBeenPressed){
button19HasBeenPressed = true;
// Button pressed - set LED 2 (PWM 13) to full brightness
ss.analogWrite(13, 255);
Keyboard.press(‘2’);
}
} else {
button19HasBeenPressed = false;
// Button released - turn off LED 1
ss.analogWrite(13, 0);
Keyboard.releaseAll(); // Releases all keys
}
// Example: Read Button 3 (Pin 20)
if (!ss.digitalRead(20)) {
if(!button20HasBeenPressed){
button20HasBeenPressed = true;
// Button pressed - set LED 3 (PWM 0) to full brightness
ss.analogWrite(0, 255);
Keyboard.press(‘3’);
}
} else {
button20HasBeenPressed = false;
// Button released - turn off LED 3
ss.analogWrite(0, 0);
Keyboard.releaseAll(); // Releases all keys
}
// Example: Read Button 4 (Pin 2)
if (!ss.digitalRead(2)) {
if(!button2HasBeenPressed){
button2HasBeenPressed = true;
// Button pressed - set LED 4 (PWM 1) to full brightness
ss.analogWrite(1, 255);
Keyboard.press(‘4’);
}
} else {
button2HasBeenPressed = false;
// Button released - turn off LED 4
ss.analogWrite(1, 0);
Keyboard.releaseAll(); // Releases all keys
}
delay(50);
}