#include #define NEOPOWERPIN 11 // Provides voltage for the built-in NeoPixel #define NEOPIXELPIN 12 // Datapin for the the built-in NeoPixel #define NUMPIXELS 1 //Amount of NeoPixels Adafruit_NeoPixel pixels(NUMPIXELS, NEOPIXELPIN, NEO_RGB + NEO_KHZ800); #define DELAYVAL 1000 // Time (in milliseconds) to pause between loop bool blinking = true; void setup() { // put your setup code here, to run once: pinMode(LED_BUILTIN, OUTPUT); // initialize digital pin LED_BUILTIN as an output. pinMode(NEOPOWERPIN, OUTPUT); // initialize digital pin NEOPOWERPIN as an output. digitalWrite(NEOPOWERPIN, HIGH); // Power for the NeoPixel pixels.begin(); Serial.begin(9600); } void loop() { // put your main code here, to run repeatedly: if (blinking) { // Blink the NeoPixel pixels.clear(); // Set all pixel colors to 'off' // We only have one pixel, therefore the first argument (index) is 0 pixels.setPixelColor(0, pixels.Color(25, 25, 180)); // Nice blue color pixels.show(); // Send the updated pixel colors to the hardware. delay(DELAYVAL); // wait between pixels.clear(); pixels.setPixelColor(0, pixels.Color(120, 120, 25)); // Nice yellow color pixels.show(); } else { // Turn of the NeoPixel pixels.clear(); pixels.show(); // Still blink the small built-it LED digitalWrite(LED_BUILTIN, HIGH); delay(DELAYVAL); digitalWrite(LED_BUILTIN, LOW); } delay(DELAYVAL); if (Serial.available() > 0) { // If there is incoming bytes in the serial: String input_str = Serial.readString(); // This reads the serial buffer to a String input_str.trim(); // remove any \r \n whitespace at the end of the String Serial.print("You wrote: "); Serial.println(input_str); // Send it back to see if this works // Set the boolean accordingly if (input_str == "blink") { Serial.println("Ok, blinking"); blinking = true; } else if (input_str == "stop") { Serial.println("Ok, stopping"); blinking = false; } } }