void loop() { HM10.listen(); // Preluare input de la HM10 if (HM10.available() > 0) { // Citire caracter si concatenare char c = HM10.read(); command += c; // Atunci cand este receptionata o comanda (16 caracatere), preia datele if (command.length() == 16) { leftCoord = command.substring(1, 4).toInt(); rightCoord = command.substring(5, 8).toInt(); forwardCoord = command.substring(9, 12).toInt(); backCoord = command.substring(13, 16).toInt(); /* In cazul in care toate coordonatele sunt 0, opreste motoarele, * altfel seteaza vitezele si directiile corepunzatoare */ if (!leftCoord && !rightCoord && !forwardCoord && !backCoord) Stop(); else { double y = (rightCoord - leftCoord) / 255.0; double x = (forwardCoord - backCoord) / 255.0; Move(x, y); } // Reseteaza buffer-ul command = ""; } } // Redare audio in continuare daca audioRepeat > 0 if (audioRepeat) { audioPlay(); audioRepeat -= 1; } else noNewTone(SPEAKER_PIN); }