hello,
I would like to use a computer keyboard to send midi notes. I use a arduino leonardo, a USB host shield in which I plug the keyboard and the midiUSB library.
here the usb host shield reference : USBhostshield
Everything works fine as long as the IDE is open, but as soon as I close the Arduino IDE application, it stops working.
It seems that the problem comes from the setup and loop needed for the keyboard.
void setup()
{
Serial.begin( 115200 );
#if !defined(__MIPSEL__)
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
#endif
Serial.println("Start");
if (Usb.Init() == -1)
Serial.println("OSC did not start.");
delay( 200 );
HidKeyboard.SetReportParser(0, &Prs);
}
void loop()
{
Usb.Task();
}
i find this piece of code in the example of the USB host shield library.
and i have a function to send midi like this
Do you know if there is a conflict between the keyboard void setup and void loop and the way the midiUSB library is working ?
once again, everything is working as long as the IDE is open, but not as a standalone device.
any idea ?
thanks a lot
you will have to explain in more detail what you want to do.
You wrote
what is the exact opposite "configuration" to
As you write that this "configuration" with opened IDE is working.
Does this opposite configuration mean:
IDE is just closed but your microcontroller (which exact type of microcontroller??) and USB-hostshield is still connected to your computer?
Your microcontroller plus USB-host-shield is connected to what kind of MIDI-device?
you should post your complete sketch from the very first to the very last line of code and you should explicitly write that this is exact that code that shows the much more detailed described behaviour
I am not too familiar with USB. My 2 cents I know about it is that the two device that are connected to each other one is the host and one is the peripheral.
Now as the thing that you connected to the microcontroller is called host-shield I would think the host-shield is acting as the host. And then the other side would be the peripheral.
standard examples:
a computer (the USB-host) has connected a USB-mouse (a peripheral)
a computer has connected a USB-keyboard (a peripheral)
I do not know what the role ( the host or the peripheral) the hapax-midi-devic is having.
As for the IDE beeing closed and it does not work
I guess this line of code explains it
The comment says it:
As long as the serial connection is not established stay in the empty while-loop
You can check this by making a led blink fast inside the while (!serial)-loop
and make it blink slower after the while(!serial)-loop
The Hajax productpage says
Hapax can sequence and synchronize all your gear.
But what does this mean in relation to beeing a host or a peripheral? I don't know