I've built a MIDI controller using arduino mega2560, that takes all my buttons and potentiometers, and converts them into midi messages.
If I upload the code via USB onto arduino and open the serial monitor, the data comes in when I press a button or turn a pot. If I unplug the USB, and plug it in again, I get nothing, unless I open the serial monitor again.
My problem is that I need arduino to start sending serial data as soon as it is powered up, as in my final design, arduino will be externally powered through VCC and GND, and not by USB, and it will be sending serial data out of the Tx pin, into my midi to usb cable.
If you want to read my code it's here: http://textuploader.com/ttg1
I've also cut the RESET-EN trace on the board (I read somewhere that this might help, but it didn't)
I've also cut the RESET-EN trace on the board (I read somewhere that this might help, but it didn't)
That's not a good idea because it probably won't help here and will make problems if you want to update your sketch.
If I upload the code via USB onto arduino and open the serial monitor, the data comes in when I press a button or turn a pot. If I unplug the USB, and plug it in again, I get nothing, unless I open the serial monitor again.
Where do you get nothing? From your description this looks like a driver (better: operating system) problem on your PC. The only difference on the Arduino is, that it gets another reset signal when you open the serial monitor.
Which release of the Mega2560 do you have? Do you have an original Arduino or a clone? If it's a clone, where is it from? Can you post pictures?
That's not a good idea because it probably won't help here and will make problems if you want to update your sketch
Yeah, I can't upload through USB anymore, I get an error, but luckily I have an USB isp programmer which works fine!
Where do you get nothing? From your description this looks like a driver (better: operating system) problem on your PC. The only difference on the Arduino is, that it gets another reset signal when you open the serial monitor.
My nothing I mean, the green tx led doesn't flash, nor do I get anything out of the Tx port into my usb-midi cable.
My nothing I mean, the green tx led doesn't flash, nor do I get anything out of the Tx port into my usb-midi cable.
The LED is controlled by the ATmega16U2 which is the onboard USB-to-serial converter. So a non-flashing LED doesn't mean that the Arduino is sending nothing. Please provide the wiring diagram for your USB-midi cable. Is that connected to the PC or to the Arduino?
My nothing I mean, the green tx led doesn't flash, nor do I get anything out of the Tx port into my usb-midi cable.
The LED is controlled by the ATmega16U2 which is the onboard USB-to-serial converter. So a non-flashing LED doesn't mean that the Arduino is sending nothing. Please provide the wiring diagram for your USB-midi cable. Is that connected to the PC or to the Arduino?
I've mspainted a quick diagram, I hope it makes sense
Let's do a very basic check if the reset circuit on your clone works correctly. Upload the Blink example sketch to your Mega, check if it works (the LED on pin 13 blinks). Then disconnect the USB and reconnect it again. Does the pin 13 LED start to blink again?
In this case the reset circuit seems to work and most probably the sketch you upload also works the same, no matter if the Serial Monitor runs or not. To eliminate the last problem that can be influenced by that move, unplug the USB and power the Arduino with an external power supply while your sketch was uploaded. If that doesn't help (you still don't see traffic on the MIDI interface), provide a link to the MIDI library you're using.
EDIT: I thought I might as well give an update to my situation as to not confuse. I've decided to scrap the idea of using the tx pins into a serial midi converter as this is proving unreliable. I'm now powering arduino through USB, but powering my components still through the external 5v supply. The two grounds are connected, and suprisingly it actually works! I assumed that the pots and buttons would have to be connected to the same power supply as arduino, but actually as long as the GND's are connected it works fine. (I'm also drawing around 2A of current through the external power supply, but this doesn't pass through arduino so it's fine)
This means I'm now just sending data out of the USB port on arduino. I plan to reprogram the atmega16u2 chip to be able to send HID MIDI messages over USB in the future, so my software can automatically pick up messages without any drivers or other software.
So I guess I've solved my problem but thank you for your cooperation!
I have a sketch that sends data from the bluno nano (BLE onboard clone) to an iOS app. The app gets(null) until I open the serial monitor, then I start getting my data. Likewise if I power the bluno from a USB-battery pack I get null and worst of all, I cant open a serial monitor in order to get my data.