Problem with write key HID

hi ;
i have this program to counter from 0000 to 9999 . all the key is good but the key “0” i see the “w”

like this :
wwww
www1
www2

please help me :disappointed_relieved:

const int ledPin = 13;
int counter = 0;

int loops = 0;
int value0 = 0;
int value1 = 0;
int value2 = 0;
int value4 = 0;
int fakecounter = counter;
char pin[]="xxxx";
uint8_t buf[8] = {0}; /* Keyboard report buffer */
void setup() {
pinMode(ledPin, OUTPUT);
Serial.begin(9600);
randomSeed(analogRead(0));
delay(200);
}
void loop(){
if (counter <= 9999){
delay(8000);
digitalWrite(ledPin, LOW);
delay(5500);
digitalWrite(ledPin, HIGH);
sprintf(pin, "%04d", fakecounter);
//First Digit
int value0 = pin[0] - '0';
buf[3] = value0 + 29;
if (buf[3] = 30){
buf[3] = value0 + 29;
Serial.write(buf, 8);
delay(450);
releaseKey();
delay(420);
}
//Second Digit
int value1 = pin[1] - '0';
buf[3] = value1 + 29;
if (buf[3] = 30){
buf[3] = value1 + 29;
Serial.write(buf, 8);
delay(398);
releaseKey();
delay(510);
}
//Third Digit
int value2 = pin[2] - '0';
buf[3] = value2 + 29;
if (buf[3] = 30){
buf[3] = value2 + 29;
Serial.write(buf, 8);
delay(421);
releaseKey();
delay(423);
}
//Forth Digit
int value3 = pin[3] - '0';
buf[3] = value3 + 29;
if (buf[3] = 30){
buf[3] = value3 + 29;
Serial.write(buf, 8);
delay(430);
releaseKey();
delay(525);
}
//Enter Key
buf[3] = 40;
Serial.write(buf, 8);
delay(305);
releaseKey();
}
//reached 4 digit PIN max value
if (counter > 9999){
for (int blinkies = 0; blinkies < 8; blinkies++) {
digitalWrite(ledPin, HIGH);
delay(20);
digitalWrite(ledPin, LOW);
delay(200);
}
delay(6000);
}
++counter;
fakecounter = counter;
}
void releaseKey()
{
buf[0] = 0;
buf[2] = 0;
buf[3] = 0;
Serial.write(buf, 8);	// Release key
}

Sorry but I have no idea what you are trying to achieve or how you are trying to achieve it.
However some things look very wrong.

char pin[]="xxxx";

What is this for? It never changes but you use it in things like

int value0 = pin[0] - '0';

Why? That variable will always contain the same value because both things on the right hand side never change.

Anyway that code does not compile, the line:-

int fakecounter = counter;

Throws an error because you have not defined the variable counter.

So can you post the code you are using please.