Arduino Leonardo Keyboard messup! Can't re-upload blank code!

I messed up with my code on my Arduino Leonardo board, and it constantly spams "AC=?" on the keyboard. I can't reupload my code because it spams the computer's receive line so much that it can't transmit the new code. I tried the hard-reset that was listed on a few sites I looked around, and all it did was keep spamming after releasing the reset button, and froze the upload. I am ripping my hair our right now trying to clear the current program, to no avail.

Here is the code that was uploaded: (it is intended to make a guitar hero controller PC compatible)

#include <Keyboard.h>

int GreenButton = 10;
int RedButton = 11;
int YellowButton = 12;
int BlueButton = 13;
// int OrangeButton;

void setup() {
  // put your setup code here, to run once:
Serial.begin(9600);
Keyboard.begin();
pinMode(GreenButton, INPUT);
pinMode(RedButton, INPUT);
pinMode(YellowButton, INPUT);
pinMode(BlueButton, INPUT);
// pinMode(OrangeButton, INPUT);
}

void loop() {
  // put your main code here, to run repeatedly:
if (GreenButton) == HIGH);
{
  Keyboard.press('v');
}
if (GreenButton) == LOW);
{
  Keyboard.release('v');  
}
if (RedButton) == HIGH);
{
  Keyboard.press('c');
}
if (RedButton) == LOW);
{
  Keyboard.release('c');
}
if (YellowButton) == HIGH);
{
  Keyboard.press('x');
}
if (YellowButton) == LOW);
{
  Keyboard.release('x');
}
if (BlueButton) == HIGH);
{
  Keyboard.press('z');
}
if (YellowButton) == LOW);
{
  Keyboard.release('z');
}
}

BEFORE YOU POINT OUT MY MISTAKE IN THE CODE; I KNOW I FORGOT TO READ THE BUTTON INPUTS

Any help on how to upload a blank sketch without it spamming the keyboard is appreciated.

In hind side, I should have added an override button to disable all the keyboard presses and break out of the loop ::slight_smile:

Double tap reset to force it to stay in bootloader and then upload good code

DrAzzy:
Double tap reset to force it to stay in bootloader and then upload good code

Oh my god, you are a saint :slight_smile: Thank you so much.