voidloop() { rec = ""; while (BT.available() > 0){ rec = char(BT.read()); Serial.println(rec); if (rec=="R"){ Serial.println("receved R"); delay(5); rec = char(BT.read()); r = true; g = false; b = false; } if (rec=="G"){ Serial.println("receved G"); delay(5); rec = char(BT.read()); r = false; g = true; b = false; } if (rec=="B"){ Serial.println("receved B"); delay(5); rec = char(BT.read()); r = false; g = false; b = true; } if (rec=="X"){ Serial.println("finished"); r = false; g = false; b = false; rr = atoi(R.c_str()); gg = atoi(G.c_str()); bb = atoi(B.c_str()); Serial.println(rr); Serial.println(gg); Serial.println(bb); R = ""; G = ""; B = ""; analogWrite(9,rr); analogWrite(10,gg); analogWrite(11,bb); } if (r==true)R+=rec; if (g==true)G+=rec; if (b==true)B+=rec; delay(10); } }
The domain name of this website has been changed to triority.cc(Using CDN via cloudflare, recommended) / www.triority.cc(Connecting directly, works better in Chinese mainland). Please contact me if you have any questions.