I am trying to run the example code for button on the daisy seed. for the button.Init function I have an error saying it needs 4 parameters (the example has three) and that the 4th param is the mode. Does anyone know what I should be entering here? I tried 1 and 0 and the led is flickering not at full strength. It’s not reacting to the button at all
here is the code
// Title: Button
// Description: Turn an led on and off with a button
// Hardware: DaisyHardware
// Author: Ben Sergentanis
// Breadboard:
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Button/resources/Button_bb.png
// Schematic:
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Button/resources/Button_schem.png
#include "DaisyDuino.h"
static DaisyHardware seed;
Switch button;
void setup() {
// setup the button
// update at 1kHz, no invert, on pin 28
button.Init(1000., true, 26, t);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// Debounce the button
button.Debounce();
// If the button is pressed, turn the LED on
digitalWrite(LED_BUILTIN, button.Pressed());
// wait 1 ms
delay(1);
}
Oh wait - I made a very simple mistake - I was using the leg number not the Dpin number to refer to my button. Now that is fixed when I set the 4th parameter to 0, it is dim and gets brighter in response to the button, 1 is on all the time, and 2 responds to the button as a momentary button.
// Title: Button
// Description: Turn an led on and off with a button
// Hardware: DaisyHardware
// Author: Ben Sergentanis
// Breadboard:
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Button/resources/Button_bb.png
// Schematic:
// https://raw.githubusercontent.com/electro-smith/DaisyExamples/master/seed/Button/resources/Button_schem.png
#include "DaisyDuino.h"
// static DaisyHardware seed;
Switch button;
void setup() {
// setup the button
// update at 1kHz, no invert, on pin 28
button.Init(1000., true, 19, 2);
pinMode(LED_BUILTIN, OUTPUT);
}
void loop() {
// Debounce the button
button.Debounce();
// If the button is pressed, turn the LED on
digitalWrite(LED_BUILTIN, button.Pressed());
// wait 1 ms
delay(1);
}
thanks, ok here is a very basic question, everyone keeps saying on that thread that the source code is the best documentation for daisyduino, where do I find that? I’ve generally been looking at the daisySp documentation.