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