what does it do and how to use it ,is there any thing wrong with it
void handleInput() {
if (Serial.available()) {
String input = Serial.readStringUntil('\n');
if (input.startsWith("m")) {
int throttle = input.substring(1).toInt();
car.setSpeed(throttle);
}else if (input.startsWith("t")){
int deg = input.substring(1).toInt();
car.setAngle(deg);
}
system
#2
,is there any thing wrong with it
Apart from the lack of context and of code tags?
Write a little test sketch that calls the function in loop(). Replace car.setSpeed by Serial.println; same for car.setAngle.
Set the serial monitor to send a newline (right bottom).
Start playing to see what happen; e.g. enter m34 in the serial monitor and press send.
This fragment listens to Serial and expects content like
t100
m50
m21
t-2
when it gets a line starting with 'm', it sets the throttle.
when nit gates a line starting with 't, it sets the angle.
anything else gets ignored.