Multiple buttons connection direct to daisy

Hi everyone,

I’m not sure what I’m doing wrong, but when I connect multiple buttons to digital pins, I keep receiving false triggers from other buttons. I tried various pins, tried GPIO or Switch class uses, and tried using resistors instead of PullUp, but it seems like I’m missing something, and I’m not sure what. Here’s the example connection I am using to connect four 2-pin buttons directly to board (I’m using an 8 pin connector as daisy seed in the breadboard designer):


The buttons are connected to pins D15 to D18 and DGND+AGND.

And the code:

#include "daisy_seed.h"
#include "daisysp.h"

using namespace daisy;
using namespace daisysp;

DaisySeed hw;
daisy::Switch b1, b2, b3, b4;

void buttonListener(daisy::Switch button, int pin) {
	if (button.RisingEdge() == 1) {
		hw.PrintLine("Pressed %d", pin);
	} else if (button.FallingEdge() == 1) {
		hw.PrintLine("Released %d", pin);
	}	
}

int main(void)
{
	hw.Init();
	hw.StartLog(true);
	hw.PrintLine("serial connected");

	b1.Init(hw.GetPin(15), 1000, daisy::Switch::TYPE_MOMENTARY, daisy::Switch::POLARITY_NORMAL, daisy::Switch::Pull::PULL_UP);
    b2.Init(hw.GetPin(16), 1000);
	b3.Init(hw.GetPin(17), 1000);
	b4.Init(hw.GetPin(18), 1000);
	
	while(1) {
		b1.Debounce();
		b2.Debounce();
		b3.Debounce();
		b4.Debounce();

		buttonListener(b1, 15);
		buttonListener(b2, 16);
		buttonListener(b3, 17);
		buttonListener(b4, 18);

	}

}

I just ran that code, unmodified, on a Seed, without using switches, just touching wires from the GPIO to ground. I didn’t get any unexpected outputs. Maybe your breadboard isn’t connecting well with the switches?

I’d normally use a delay to limit the rate at which the loop runs - but it didn’t seem necessary for me.

I just realized I was using a custom breakout board, which had some internal connections between pins that were not clearly marked. I’ve switched to breadboard and it worked perfectly, thanks for verifying the code!