I was using and Arduino Micro in Arduino IDE and I noticed my serial.print wasn't working. I wrote this simple code and still have not been able to get anything to show up on the serial monitor.
I have set the baud rate in the program to 9600 as well as in the monitor, so that is not the problem. At first I thought it was a problem with USB3.0 (which has worked in the past). I have tried every USB port on my computer and still not working. When doing this I switched the serial port every switch and the board is showing up. I have two micros and I have tried both, so i think the problem isn't the board. The TX light indicates it isn't trying transmitting every time I press the reset button with this code, so I think the code never properly uploaded, despite no error message. I tried switching the USB wire and it still didn't work, so there is not faulty connection. Both the TX and RX Lights work and actually light up when I upload the code. Again with this code nothing is showing up in the serial monitor and when I press reset the pin13 Light goes low while holding it down, I release and the 13 light goes high but neither the TX or RX lights light up. I am using 1.6.12 IDE version.
while(!SerialUSB && millis()<5000) {
//wait for USB serial to connect or 5 seconds to elapse
}
SerialUSB.println("Name Of Sketch");
SerialUSB.print(" Version: ");
SerialUSB.println(VERSION);
SerialUSB.print("Compiled on ");
SerialUSB.print(__DATE__);
SerialUSB.print(" at ");
SerialUSB.println(__TIME__);
SerialUSB.println();
Where VERSION is a #define string. (You don't have to have it, but it can be incredibly useful a year from now.)
If you also run this on other types of Arduinos that don't have SerialUSB, you can #define SerialUSB Serial
//wait for USB serial to connect or 5 seconds to elapse
}
SerialUSB.println("Name Of Sketch");
SerialUSB.print(" Version: ");
SerialUSB.println(VERSION);
SerialUSB.print("Compiled on ");
SerialUSB.print(DATE);
SerialUSB.print(" at ");
SerialUSB.println(TIME);
SerialUSB.println();
I'd be inclined to go for a solution that doesn't waste quite so much precious RAM.
When you've got a few devices out in the field and you don't know which software was loaded onto which one because someone else has been plug-and-playing them, then getting that version number back is worth a lot more than just RAM.