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.