Commands via grbl

well i want to send a command to grbl when a button is touched i modified the firmware to detect the button but i don't know how to send the commands and execute it becuase i only send to the seria like a text but it dont do anything, i think the far thing i do is these.

[14:41:59] [ ]G0 X100 F100<Idle|MPos:0.000,0.000,0.000|Bf:15,128|FS:0,0>
[14:41:59] [ ] [$J=G0X100F100] G0 X100 F100<Idle|MPos:0.000,0.000,0.000|Bf:15,128|FS:0,0>
but i dont know because it dont do anything, can somebody healp me, it is a predone pcb so i cannot connect an arduino, or at leats i dont know how

it is a esp32 of mks that the name es dlc32 but i dont want to connect another microcontroller these detect the button and send but only that can anyone know what i am doing wrong?

these are all the code that i try if (currentButtonState == LOW && lastButtonState == HIGH) {
//gc_execute_line("G1 X10 Y10 F1000",CLIENT_SERIAL);
Uart0.flush();
Serial.flush();
// Serial.println("probando");
//Serial.print("\r\n");

      // Serial1.println("G0 X100 F1000");
       //Serial1.print("\r\n");

       //Serial.println("G0 X100 F1000");
      // Serial.print("\r\n");
      // Uart0.println("G0 X100 F10002");
      Uart0.write("[$J=G0X100F5500]\r\n");  // Envía el comando G-code
      Uart0.write('\n');  // Agrega el salto de línea necesario para GRBL}
     
     //grbl_sendf(CLIENT_ALL,"G0 X100 F100\r\n");
    
      // protocol_auto_cycle_start();
      // protocol_execute_realtime();
       //String lastFile = readLastFileName();  // Leemos el nombre del archivo guardado
    
       //if (lastFile.startsWith("/")) {
        // lastFile = lastFile.substring(1);
      // }
       //String nombreson = "[ESP220] " + lastFile;  // Ahora nombreson es un String
       //enviarGcode(nombreson.c_str());  // Convierte String a const char*
       



        while (digitalRead(buttonPin) == LOW) {
            delay(10);  // Pequeña espera para evitar rebotes del botón
        }
    } lastButtonState = currentButtonState;  // Actualizamos el estado anterior

Please read and use this link: How to get the best out of this forum - Development Tools / IDE 1.x - Arduino Forum

Your other topic on the same subject deleted.

Please do not duplicate your questions as doing so wastes the time and effort of the volunteers trying to help you as they are then answering the same thing in different places.

Please create one topic only for your question and choose the forum category carefully. If you have multiple questions about the same project then please ask your questions in the one topic as the answers to one question provide useful context for the others, and also you won’t have to keep explaining your project repeatedly.

Repeated duplicate posting could result in a temporary or permanent ban from the forum.

Could you take a few moments to Learn How To Use The Forum

It will help you get the best out of the forum in the future.

Thank you.