"Switch" class in daisyduino

Does any one know what the different modes for switch class object is?

this line:
button.Init(1000, true, 28, 0);

1000 is refresh rate, true is change of polarity, 28 is PIN number. But what is “mode” 0? And how many modes are there?

1 Like

Looking at DaisyDuino/src/utility/switch.cpp at master · electro-smith/DaisyDuino · GitHub , I see that Init calls pinMode(pin, mode). Looking up pinMode in the Arduino docs, I see that mode can be INPUT, OUTPUT, or INPUT_PULLUP. Since we’re talking about a button, we want the pin to be an input, so I surmise that mode 0 is INPUT.

Or INPUT_PULLUP, depending on the circuit, I guess.

Just to be sure, I printed out the three constants: INPUT is 0, OUTPUT is 1, and INPUT_PULLUP is 2.

Then I looked at the DaisyDuino/seed/Button example and saw that it calls Init with only three arguments: button.Init(1000, true, 28);

But that causes a compilation error!

As a newcomer to the Daisy Seed, I gotta say I’m not impressed with the broken toolchain (C++), the lack of documentation, and the broken example code(!)

Welcome mpark!

button.Init(1000, true, 28, INPUT_PULLUP); will work.

And we should fix that button example code since the `INPUT_PULLUP` is indeed missing. Thank you for pointing that out.