#include <Adafruit_NeoPixel.h>
#define PIN 5 // Neopixel pin
#define PIX 12 // Number of Neopixels
Adafruit_NeoPixel pixels = Adafruit_NeoPixel(PIX, PIN, NEO_GRB + NEO_KHZ800);
unsigned long fullTime = 20;
void setup() {
Serial.begin(115200);
pixels.begin(); // initialize a Neopixel object/instance on pin 3
pixels.clear(); // clear any set pixels in the buffer
pixels.show(); // display the pixel buffer
}
void loop() {
fuel(fullTime, millis() / 1000); // "full" time and "now" time
}
void fuel(unsigned long whole, unsigned long part) {
unsigned long value = PIX * part / whole;
for (int i = 0; i < value; i++) {
pixels.setPixelColor(i, pixels.Color(255, 255, 255));
pixels.show();
}
}