when i press button, in serial incomes aa string that activates bool, and if it = true, then i can declare speed of the motor, but code works onlu a few times and then nothing.
if (Serial.available() > 0) {
String s = Serial.readStringUntil('\n');
if (s == "aa") {
initial = !initial;
}
if(initial == true){
jj = Serial.parseInt();
if(jj >0 && jj <=255){
analogWrite(3, jj);
}
} else if(!initial){
digitalWrite(3, LOW);
}
}
I moved your topic to an appropriate forum category @robot0889.
In the future, please take some time to pick the forum category that best suits the subject of your topic. There is an "About the _____ category" topic at the top of each category that explains its purpose.
What sequence is it supposed to respond to? Post the characters that you expect to read, and post enough of them so we get the idea of what you are looking for from the serial stream.