Hello, I'm new here and so far it's been a great experience. Up until last friday I had never touched an arduino board, or soldered, or had much experience with C++.
I'm working on a project and so far I've been able to overcome all of my obstacles, but I'm really really stuck on this part.
I have an app that sends data to the serial monitor. The app has 3 slider buttons and needs to have a start/stop button.
Sider 1 sends a 1-10 to the serial monitor, slider 2 sends 20-30, slider 3 sends 40-50.
my code goes like this:
if(SerialBT.available())
{
state = SerialBT.readStringUntil('\n');
Serial.println(state);
newState = state.toInt();
}
if(newState > 0 && newState < 11)
{
variableOne = newState;
}
else if(newState > 19 && newState < 31)
{
variableTwo = newState;
}
else if(newState > 39 && newState < 51)
{
variableThree = newState;
}
ledcWrite(0, variableOne);
delay(variableTwo);
ledcWrite(0, 0);
delay(variableTwo);
delay(variableThree);
}
I need a start/stop button though because right now if I run the app and start messing with sliders things don't go as planned.
like
if(SerialBT.read() == 'start')
{
read serial monitor for variables 1, 2, and 3. Do loop
}
else if(SerialBT.read() == 'stop')
{
return; wait for if(SerialBT.read() == 'start')
}
but I can't find a way that actually does that and I don't know how to make it read the 3 lines before the "start" button. Maybe I'm just thinking about it wrong. Any help would be greatly appreciated.