#include <Adafruit_NeoPixel.h>
#include <math.h>

#define PIN_WS2812B 26  // The ESP32 pin GPIO16 connected to WS2812B
#define NUM_PIXELS 12   // The number of LEDs (pixels) on WS2812B LED strip

int area_num = 3, area1 = 4, area2 = 8, area3 = 12;

Adafruit_NeoPixel ws2812b(NUM_PIXELS, PIN_WS2812B, NEO_GRB + NEO_KHZ800);

void setup() {
  pinMode (PIN_WS2812B, OUTPUT);
  ws2812b.begin();  // initialize WS2812B strip object (REQUIRED)
}

void loop() {
  ws2812b.clear();  // set all pixel colors to 'off'. It only takes effect if pixels.show() is called

  // turn pixels to green one-by-one with delay between each pixel
  for (int pixel = 0; pixel < area1; pixel++) {         // for each pixel
    ws2812b.setPixelColor(pixel, ws2812b.Color(255, 0, 0));  // it only takes effect if pixels.show() is called
    ws2812b.show();                                          // update to the WS2812B Led Strip
    delay(100);  // 500ms pause between each pixel
  }

  /*
  ws2812b.clear();
  ws2812b.show();  // update to the WS2812B Led Strip
  delay(1000);     // 2 seconds off time,
  */

  // turn on all pixels to red at the same time for two seconds
  for (int pixel = area1; pixel < area2; pixel++) {         // for each pixel
    ws2812b.setPixelColor(pixel, ws2812b.Color(0, 255, 0));  // it only takes effect if pixels.show() is called
  }
  ws2812b.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second on time

  for (int pixel = area2; pixel < area3; pixel++) {         // for each pixel
    ws2812b.setPixelColor(pixel, ws2812b.Color(0, 0, 255));  // it only takes effect if pixels.show() is called
    ws2812b.show();                                          // update to the WS2812B Led Strip
    delay(100);  // 500ms pause between each pixel
  }

  /* turn off all pixels for one seconds
  ws2812b.clear();
  ws2812b.show();  // update to the WS2812B Led Strip
  delay(1000);     // 1 second off time
  */
}