My Arduino Leonardo was working properly but for the last two hours when I connect it to a PC via a USB cable, it is reporting something like USB is not recognized
and even in device manager it is not showing. However, when I press the restart button on the Arduino, the PC will detect it as an Arduino Leonardo bootloader(com 7)
but after few seconds it disappears. What do I have to do? I tried to restart the PC, changed USB cable but the same issue occurs. I checked the USB by connecting another device - it works fine but the Arduino is not recognised.
I tried other PCs also but the same problem continued. What do I have to do?
3 Answers
It is highly likely that the sketch you loaded is causing this.
However, when I press the restart button on the Arduino, the PC will detect it as an Arduino Leonardo bootloader(com 7) but after few seconds it disappears.
For a few seconds after reset the bootloader will configure the board as a USB serial device, awaiting upload of a new sketch. Once that times out it runs the existing code. If the existing code does not configure the USB port (eg. by doing Serial.begin
) then it will cease to enumerate as a USB device. This is perfectly normal.
The "fix" is to upload a sketch that uses the USB interface. For example, open a serial port, open the keyboard (Keyboard.begin()
) or similar.
Nick Gammon's solution worked for me. I am adding the arduino code I used below.
While Arduino Leonardo is connected to your computer, press its reset button. A COM for Arduino Leonardo appears under the Arduino IDE: Tools > Port: You should upload the code within a few seconds just after you press the reset button while the Leonardo COM is appearing.
The following is the code I used:
// Start of Code
void setup() {
// make pin 2 an input and turn on the
// pullup resistor so it goes high unless
// connected to ground:
Serial.begin(9600);
pinMode(13,OUTPUT);
digitalWrite(13,HIGH);
pinMode(2, INPUT_PULLUP);
Keyboard.begin();
}
void loop() {
//if the button is pressed
if(digitalRead(2)==LOW){
//Send the message
Keyboard.print("Hello!");
}
delay(1000);
digitalWrite(13,HIGH);
delay(1000);
digitalWrite(13,LOW);
}
// End of Code
-
It is more reliable the other way around: Start the upload process and wait for the "PORTS ..." lines to appear (in the Arduino log window at the bottom of the screen). Only then press the "RESET" button. Commented Mar 29, 2020 at 1:59
It could be the settings of the serial port (you mentioned com 7). Try going on your Arduino Integrated Development Environment.
Go to Tools > Serial Port > (and try putting this setting on different serial ports)
If the Serial Port is grayed out and you cant press it, try restarting the Arduino with the restart button, and hopefully you will have an opportunity to change the Serial Port in those few seconds that the Arduino is recognized. Try all the different Serial Ports your computer has.