I use android to send the data to Arduino. when i send 0x02, LED turn on, and the breathing LED code are work. But when i send 0x03, it can not turn off the LED. i use UNO R3 the bluetooth is HC06
char data;
void setup()
{
Serial.begin(9600);
pinMode(9, OUTPUT);
}
void loop()
{
if (Serial.available())
{
data = Serial.read();
switch(data){
case 0x02:
for (int a = 0 ; a < 255; a=a-1){
analogWrite(9, a);
delay(10);
}
for (int a = 255; a>0; a=a-1){
analogWrite(9, a);
delay(10);
}
break;
case 0x03 :
digitalWrite(9, LOW);
break;
default:
break;
}
}
}
for (int a = 0 ; a < 255; a=a-1){
. It should breathe once and then it'll stop. However it's hard to interrupt something, when you are busy with breathing – KIIV Apr 5 '18 at 5:27