Skips code on first time use?

Hey guys, I been playing around with a "BadUsb". My problem is that when I plug in the usb to a new computer, it skips the print username line. When I try it again on the same computer it executes prefectly. I tried increasing the delay. I assume it's some first time use lag?

any ideas?

//simple log-in starter project

#include "Keyboard.h"
void setup() {
// put your setup code here, to run once:

Keyboard.begin();
delay(4000); // I have tried increasing this
Keyboard.print("Username"); //put username here , skips this line
delay(1000);
Keyboard.write(KEY_TAB); // also skips this
delay(1000);
Keyboard.print("Password"); //put pass here
delay(1000);
Keyboard.write(KEY_RETURN);
Keyboard.end();

}

void loop() {
// put your main code here, to run repeatedly:

}

When Windows detects something new plugged in, it will check/install the correct driver for it before it is "ready" and this often times takes a while. Once done, the next time you plug it in, Windows recognizes it and is immediately ready.

Yeah I figured. Thanks anyway for your input. :slight_smile:

Try to wait before calling begin():

void setup() {

  delay(4000); //  try increasing this if necessary
  Keyboard.begin();

I think this worked! Thanks!