#include #define PIN 9 #define NUMPIXELS 3 int flag=0; int in_error=0; Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, PIN, NEO_GRB + NEO_KHZ800); int incomingByte; // a variable to read incoming serial data into void setup() { // initialize serial communication: Serial.begin(9600); // initialize the LED pin as an output: pixels.begin(); // This initializes the NeoPixel library. pixels.setPixelColor(0, pixels.Color(8,9,10)); // Moderately bright green color. pixels.show(); // This sends the updated pixel color to the hardware. delay (100); pixels.setPixelColor(0, pixels.Color(0,0,0)); // Moderately bright green color. pixels.show(); } void loop() { // see if there's incoming serial data: if (Serial.available() > 0) { // read the oldest byte in the serial buffer: incomingByte = Serial.read(); Serial.println(incomingByte); switch (incomingByte) { case 48: //0 = off off_(); break; case 84: //T tristan(); break; case 86: //V valentin(); break; case 69: //E ethan(); break; case 50: //2 two(); break; case 51: //3 three(); break; case 88: //x in_error=1; break; } } if ( in_error == 1) { if (flag == 0){ pixels.setPixelColor(0, pixels.Color(20,0,0)); // Moderately bright green color. pixels.setPixelColor(1, pixels.Color(20,0,0)); // Moderately bright green color. pixels.setPixelColor(2, pixels.Color(20,0,0)); // Moderately bright green color. pixels.show(); // This sends the updated pixel color to the hardware. flag=1 ; delay (100); } if (flag == 1){ pixels.setPixelColor(0, pixels.Color(0,0,0)); // Moderately bright green color. pixels.setPixelColor(1, pixels.Color(0,0,0)); // Moderately bright green color. pixels.setPixelColor(2, pixels.Color(0,0,0)); // Moderately bright green color. pixels.show(); // This sends the updated pixel color to the hardware. flag=0 ; delay (300); } } }