//Bluetooth #include <SoftwareSerial.h> SoftwareSerial BT05(9, 10); // TX,RX char appData; String inData = ""; //neopixel #include <Adafruit_NeoPixel.h> #define PIN 4 // pin connected to the NeoPixels #define NUMPIXELS 138 // no. of led Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); //neopixel array patterns const PROGMEM uint8_t smile[] = { // smile pattern 137,136,129,128,125,124,121,120,113,112,105,104,101,100,97,96,89,88,77,75,70,68,48,47,46,45,44,43,42,41,38,31,22,27,16,13,5,4 }; int patternsmile = sizeof(smile); const PROGMEM uint8_t evil[] = { // evil pattern 117,116,109,108,107,106,105,104,101,100,99,98,89,90,95,96,67,65,52,50,38,31,22,23,24,25,26,27 }; int patternevil = sizeof(evil); const PROGMEM uint8_t cry1[] = { // cry1 pattern 125,124,120,119,109,110,112,114,115,117,98,99,100,101,103,104,105,106,89,90,91,95,96,87,85,69,37,36,35,34,33,32 }; int patterncry1 = sizeof(cry1); const PROGMEM uint8_t cry2[] = { // cry2 pattern 125,124,121,120,109,110,112,113,114,116,106,105,104,103,102,101,100,99,90,91,94,95,96,80,78,76,43,44,45,46,37,32,22,27,17,12,3,4,5,6 }; int patterncry2 = sizeof(cry2); const PROGMEM uint8_t me[] = { // me pattern 137,136,129,128,125,124,121,120,113,112,105,104,101,100,97,96,89,88,77,75,70,68,46,45,44,43,37,32,27,22,17,12,6,5,4,3 }; int patternme = sizeof(me); const PROGMEM uint8_t patiri[] = { // patiri pattern 121,127,109,110,115,116,106,105,100,99,89,90,95,96,79,80,85,86,41,42,43,44,45,46,47,48,38,31,21,28,17,12,3,4,5,6 }; int patternpatiri = sizeof(patiri); const PROGMEM uint8_t suya[] = { // suya pattern 107,98,89,90,91,92,93,94,95,96,677,65,67,52,50,41,42,43,44,45,46,47,48,38,31,22,27,16,13,4,5 }; int patternsuya = sizeof(suya); const PROGMEM uint8_t mu[] = { // mu pattern 127,126,119,118,110,111,114,115,103,102,90,91,94,95,87,86,79,78,67,65,52,50,38,31,22,27,16,15,14,13 }; int patternmu = sizeof(mu); const PROGMEM uint8_t nikori[] = { // nikori pattern 126,125,120,119,108,109,110,115,116,117,107,106,105,100,99,98,89,90,95,96,67,65,52,50,41,42,43,44,45,46,47,48,38,31,21,28,17,12,3,4,5,6 }; int patternnikori = sizeof(nikori); const PROGMEM uint8_t chuu[] = { // chuu pattern 127,126,120,119,110,111,115,116,103,100,99,90,91,95,96,87,86,67,65,52,50,44,45,36,33,23,26,15,14 }; int patternchuu = sizeof(chuu); const PROGMEM uint8_t tere[] = { // tere pattern 127,121,109,110,115,116,106,105,100,99,90,89,80,95,96,86,85,80,79,67,65,52,50,21,28,17,12,3,4,5,6 }; int patterntere = sizeof(tere); const PROGMEM uint8_t shock[] = { // shock pattern 129,130,131,135,127,123,120,108,112,115,104,100,90,95,80,85,65,52,62,61,60,57,56,55,40,44,45,49,39,30,29,20,19,15,14,10,1,2,3,6,7,8 }; int patternshock = sizeof(shock); const PROGMEM uint8_t wink[] = { // wink pattern 119,118,110,111,114,115,105,104,102,90,91,94,95,85,84,79,78,67,65,52,50,41,42,43,44,45,46,47,48,38,31,22,27,16,15,14,13 }; int patternwink = sizeof(wink); const PROGMEM uint8_t pero[] = { // pero pattern 127,126,119,118,110,115,104,103,102,101,87,85,80,78,62,61,40,43,39,38,36,31,30,22,23,15,14,26,27 }; int patternpero = sizeof(pero); const PROGMEM uint8_t uwu[] = { // uwu pattern 128,131,133,136,127,124,122,119,108,124,122,119,108,111,113,116,107,104,102,99,88,91,93,96,87,84,82,79,68,71,73,76,66,65,53,52,40,48,39,31,21,24,27 ,18,16,14,12,2,6 }; int patternuwu = sizeof(uwu); //blink function const PROGMEM uint8_t normal[] = { // normal pattern 110,111,114,115,105,104,101,100,90,91,94,95,85,84,81,80,39,30,21,28,17,16,15,14,13,12 }; int patternnormal = sizeof(normal); const PROGMEM uint8_t blink[] = { // blink pattern 39,30,21,28,17,16,15,14,13,12,88,97,86,85,84,83,82,81,80,79 }; int patternblink = sizeof(blink); //blink timer unsigned long ms; //time from millis() unsigned long msLast; //last time the LED changed state boolean blinkState = 0; //current LED state #define LED_ON 5000 #define LED_OFF 200 // interval at which to blink (milliseconds) void setup() { //bluetooth Serial.begin(115200); Serial.println("BT05 serial started at 9600"); BT05.begin(9600); // set HM10 serial at 9600 baud rate //neopixels int led = 0; pixels.begin(); // This initializes the NeoPixel library. pixels.setBrightness(50); for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off pixels.show(); } void loop() { //bluetooth BT05.listen(); // listen the HM10 port while (BT05.available() > 0) { // if HM10 sends something then read appData = BT05.read(); inData = String(appData); // save the data in string format Serial.write(appData); } // if statement if ( inData == "A") { //off for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off pixels.show(); delay(500); } if ( inData == "B") { //smile //neopixel int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternsmile; point++) { // read out the pattern led = pgm_read_byte_near(&smile[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "C") { //evil int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternevil; point++) { // read out the pattern led = pgm_read_byte_near(&evil[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "D") { //cry 1 int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patterncry1; point++) { // read out the pattern led = pgm_read_byte_near(&cry1[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "E") { //cry 2 int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patterncry2; point++) { // read out the pattern led = pgm_read_byte_near(&cry2[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "F") { //me int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternme; point++) { // read out the pattern led = pgm_read_byte_near(&me[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "G") { //patiri int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternpatiri; point++) { // read out the pattern led = pgm_read_byte_near(&patiri[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "H") { //suya int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternsuya; point++) { // read out the pattern led = pgm_read_byte_near(&suya[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "I") { //mu int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternmu; point++) { // read out the pattern led = pgm_read_byte_near(&mu[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "J") { //nikori int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternnikori; point++) { // read out the pattern led = pgm_read_byte_near(&nikori[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "K") { //chuu int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternchuu; point++) { // read out the pattern led = pgm_read_byte_near(&chuu[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "L") { //tere int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patterntere; point++) { // read out the pattern led = pgm_read_byte_near(&tere[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "M") { //shock int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternshock; point++) { // read out the pattern led = pgm_read_byte_near(&shock[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "N") { //wink int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternwink; point++) { // read out the pattern led = pgm_read_byte_near(&wink[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "O") { //pero int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternpero; point++) { // read out the pattern led = pgm_read_byte_near(&pero[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "P") { //UWU //neopixel int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternuwu; point++) { // read out the pattern led = pgm_read_byte_near(&uwu[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern pixels.show(); delay(500); } if ( inData == "Q") { //blink ms = millis(); if (ms - msLast > (blinkState ? LED_ON : LED_OFF)) { int led = 0; if (blinkState == LOW) { int led = 0; for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternnormal; point++) { // read out the pattern led = pgm_read_byte_near(&normal[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} // increment next point in pattern blinkState = HIGH; } else { for(int i=0;i<NUMPIXELS;i++){pixels.setPixelColor(i, pixels.Color(0,0,0));} //set to off for(int point = 0; point < patternblink; point++) { // read out the pattern led = pgm_read_byte_near(&blink[point]); pixels.setPixelColor(led, pixels.Color(255,20,147));} blinkState = LOW; } pixels.show(); msLast = ms; delay(500); } } }