Error Arduino Micro Pro

Hi

After uploading some code to the Arduino Micro Pro, the HID device isn't recognized anymore by Windows.
I don't know what I've done wrong, but I can't find anything wrong in the code.

This is what I've uploaded:

#include <Keyboard.h> // The main library for sending keystrokes.

void setup() 
{
 Keyboard.begin();  // Initialise the library.
}

// Loop around waiting for a button press on pin 2.
// When the button is pressed, go to the function triggerAutomation.
void loop() 
{
  if(digitalRead(2) == HIGH)
  {
    triggerAutomation();    
  }
}

void triggerAutomation()
{
  Keyboard.press(KEY_LEFT_GUI);     // Press and hold the Windows key.
  Keyboard.press('r');              // Press and hold the 'r' key.
  delay(100);                       // Wait for the computer to register the press.
  Keyboard.releaseAll();            // Release both of the above keys.
  delay(1000);                      // Wait for the Windows Run Dialog to open.
  Keyboard.print("Notepad");        // Type "Notepad".
  Keyboard.press(KEY_RETURN);       // Press the Enter key.
  delay(100);                       // Wait for the computer to register the press.
  Keyboard.releaseAll();            // Release the Enter key.
}

The Verify of the code gives me no error, but when I reconnect the Arduino Micro Pro again the following error pops up: "USB device nog recognized"

The only thing I can do is completely reset the Arduino by shorting a wire to the RST and GND pin when uploading the sketch (as far as I can see on the internet).
But because I don't know what's wrong with the code, I think the error pops up againt after uploading.

Can anybody take a look at my code and tell me what I did wrong, or can help me in the right direction ?

Gr. Edwin.

There no such thing as an Arduino Micro Pro. Sparkfun has a Pro Micro but you might see that you need to provide a link to the board you're actually using. Arduino has an Arduino Pro or an Arduino Micro but the combination doesn't exist.

Can anybody take a look at my code and tell me what I did wrong, or can help me in the right direction ?

What type of board did you choose while compiling/uploading? What version of the IDE are you using?

You didn't set the pinMode() on your input pin. Do you have a pull-down resistor to keep the input pin from floating?

I've contacted the seller and I know what the problem is.

I've orderd an ATmega34U4, 5V, 16MHz, but I received a 3.3V 8MHz.
In the Arduino IDE I've selected the wrong version. I assumed I've got the board I odered, but it was the wrong one.

I flashed the board and returned it to the seller so he can send me the 5V board.

I guess you meant ATmega32U4, I'm not aware of a ATmega34U4. The ATmega32U4 is almost always a 5V version because it's directly connected to the USB bus. If you got a 3.3V 8MHz version you probably got an Arduino Pro Mini which uses an ATmega328p.