Загрузка данных


#include <Adafruit_NeoPixel.h>

#define LED_PIN 2
#define LED_COUNT 6
#define BUTTON_PIN 4

Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);

int mode = 0;

void setup() {
  pinMode(BUTTON_PIN, INPUT_PULLUP);

  strip.begin();
  strip.setBrightness(50);

  showColor();
}

void loop() {

  if (digitalRead(BUTTON_PIN) == LOW) {

    mode++;

    if (mode > 4) {
      mode = 0;
    }

    showColor();

    // Ждём, пока кнопку отпустят
    while (digitalRead(BUTTON_PIN) == LOW) {
      delay(10);
    }

    delay(100);
  }
}

void showColor() {

  strip.clear();

  if (mode == 0) {
    setAll(255, 0, 0);       // КРАСНЫЙ
  }

  if (mode == 1) {
    setAll(0, 255, 0);       // ЗЕЛЁНЫЙ
  }

  if (mode == 2) {
    setAll(0, 0, 255);       // СИНИЙ
  }

  if (mode == 3) {
    setAll(255, 0, 255);     // ФИОЛЕТОВЫЙ
  }

  if (mode == 4) {
    setAll(255, 100, 0);     // ОРАНЖЕВЫЙ
  }

  strip.show();
}

void setAll(byte r, byte g, byte b) {

  for (int i = 0; i < LED_COUNT; i++) {
    strip.setPixelColor(i, strip.Color(r, g, b));
  }

  strip.show();
}