I am having problems to run the Momentary_Switch.cpp example. The led on my patch.init() will not lighten up. I am using the following code.
I read somwhere that i should add System::Delay(1); to the while loop. But that seems pointless to me.
Any ideas?
#include "daisy_patch_sm.h"
#include "daisysp.h"
using namespace daisy;
using namespace patch_sm;
using namespace daisysp;
/** Hardware object for the patch_sm */
DaisyPatchSM patch;
/** Switch object */
Switch button;
int main(void)
{
/** Initialize the patch_sm hardware object */
patch.Init();
/* Initialize the switch
- We'll read the switch on pin B7
*/
button.Init(patch.B7);
/** loop forever */
while(1)
{
/** Debounce the switch */
button.Debounce();
/** Get the current button state */
bool state = button.Pressed();
/** Set the onboard led to the current state */
patch.SetLed(state);
}
}
Hi,
I don’t have a patch init, but I think the led is connected to the CV_OUT_2 (C1). So maybe try this:
/** loop forever */
while(1)
{
/** Debounce the switch */
button.Debounce();
/** Get the current button state */
bool state = button.Pressed();
/** Set the onboard led to the current state */
patch.WriteCvOut(CV_OUT_2,state ? 5.f : 0.f);
}
thanks for your suggestion. Unfortunatly this didnt change anything. No led flash under c++.
I did another test with puredata to be sure that the led is working. With pd2dsy I had no problems to let the led flash. Also the led flashes once when powering on the module.
SInce I am starting with the daisy vscode environment I did a small but crucial mistake.
I switched from using:
CTRL P +
task build_and_program_dfu
to
make program-dfu
in my bash. I thought both commands compile my code before uploading but only the first one does. for the second one I have to use make beforehand.
Now everything works like expected…