Hello, I'm building a project using arduino, ws2812b led strips and hc05 bluetooth. The idea is to control the leds with different modes depending on the data received from a mobile phone.
I have two modes and a global variable that defines which mode is running, for example:
bool music = false;
void setup(){
//setup
}
void loop() {
someStuff();
if(music){
handleMusic();
}else{
if (miBT.available()){
String r = miBT.readString();
if(r.charAt(0) == 'M'){
music = true;
}else{
handleOtherModes(r);
}
}
}
}
The problem is when I set music = true, the code not works, it seems that is not entering the loop. However, if I remove that line, the code works correctly and the other modes work fine. Also if I set music = true at its definition, the music mode runs correctly.
I don't know if I'm forgetting something about setting global variables in loop or something. The code is a pseudocode, because the original is pretty long.
Thanks in advice.