Pin Lock wrong code?

hi
i have a arduino micro board r3. Im having problems with the arduino. first of all how do i factory reset it or how do i upload new sketches?. I've tried the ground reset+pin and button. I'm trying to run a sketch on it that would brute force my mbp 4 digit pin lock. I've manage to run a sketch but after the 5th attempt it won't restart the computer, therefore the arduino keeps inputting the next 4 digits (no 1 minute delay). Even when its timed out for 1 minute. Can some one point me into the right direction? heres the code I'm using. i got it off another thread here. thank you any help would be appreciated.

void setup() 
{ 
}

void loop() 
{
 static unsigned short pin;
 static char buffer[5];
 
 if ( pin < 9999 )
 {
   sprintf( buffer, "%04hu", pin );
   Keyboard.println( buffer );
   ++pin;
   delay( 10000 );
 }
 else
 {
   // Indicate finish (e.g. flash the on-board LED)
 }
}

The only way to "factory reset" an Arduino is to burn a fresh bootloader. You need an ISP device for that.

If you want it to not run your last sketch when you provide power you have to upload a different sketch. Upload this sketch to have the Arduino do nothing:

void setup(){} void loop() {}

To upload a new sketch you select the board type and serial port in the IDE and click on the upload button for the sketch.

You have a 10-second delay (10,000 milliseconds) so that is why there is no 1-minute delay.

Thanks for your help. I learned that after playing with the reset button on the board. Does any one have a a brute force code for a arudino micro?. That doesn't let the computer go to sleep. If so can you p.m. me I have one that the count is thrown off after the mbp falls asleep.