so im using arduino leonardo for a usb midi device (im switching to arduino due for a faster clock speed) but my question is, im running it as a midi "device" can it be a device and also run codes for lights or do i have to run that on a different board, id hope to only have to have one cable out of the actual device but if so then that is just what ill do
Hello
Yes, you can.
Take view into this thread to gain the knowledge.
Have a nice day and enjoy coding in C++.
thank you for this reply its very interesting but it doesn't tackle the idea of the arduino pretending to be a HID device and if a separate unrelated task gets in way of that, it just shows that you can move a servo and blink lights as well (proofing that you can have a single code for multiple things at the same time) but im worried that it cant be a hid device aaand do task outside of that function
Yes most of my projects do.
In one I was running a rotary encoder and an OLED display, all be it for musical purposes.
However, if you want to run addressable strips like the WS2812, then the transfer of data to the chips disables the interrupts for however long it takes the strip(s) to update. This might cause some latency issues, which could cause MIDI messages to be missed or delayed, depending how they were coming in.
The way round this is to use the APA102 type of addressable strips. These have two pins that control the data, a clock and data pin. This can be driven in an way that doesn't require the interrupts to be disabled.
If you insist on using a WS2812 then I have used them driven by an ATiny85, and communicated to that with an interruptible SPI like protocol.
This is a schematic of how I did that.
The pins from the Arduino are not special and can be replaced with any spare ones you have.
interesting, ill definitely opt to do your route and have you done this with hid device running of the arduino i was going for WS2813 just because i have it
Hello karigisla
Why don't I understand your answer?
The CPU of an MCU doesn't give a damn about what program code goes through its registers. Most of the time the CPU of the Arduino DUE is waiting for work and so you can give the CPU a task as a MIDI task and e.g. a task for the stage lighting.
it has nothing to do with the cpu, its about my computer seeing the arduino as a specific hid device, in this case the computer interacts with the arduino as a midi device so the arduino is pretending to be a midi keyboard and im wondering if that function gets interrupted if im trying to run unrelated functions
Ok, that was a perfect misunderstanding due to inaccurate information given.
Have a nice day and enjoy coding in C++.
what was the inaccurate information
