36 lines
919 B
C++
36 lines
919 B
C++
#include <SevenSegmentNeoPixel.h>
|
|
|
|
// Adjust these for your hardware setup
|
|
#define DIGITS 1
|
|
#define PIXELS_PER_SEGMENT 7
|
|
#define PIN 0
|
|
|
|
SevenSegmentNeoPixel display(DIGITS, PIXELS_PER_SEGMENT, PIN);
|
|
|
|
void setup() {
|
|
display.begin();
|
|
display.setBrightness(50); // Adjust brightness as needed
|
|
}
|
|
|
|
void loop() {
|
|
static unsigned long lastUpdate = 0;
|
|
static unsigned long counter = 0;
|
|
unsigned long now = millis();
|
|
|
|
if (now - lastUpdate >= 1000) { // Update every second
|
|
lastUpdate = now;
|
|
|
|
// Display the counter value, right-aligned, with leading zeros
|
|
unsigned long value = counter;
|
|
for (int d = DIGITS - 1; d >= 0; d--) {
|
|
uint8_t digit = value % 10;
|
|
display.setDigit(d, digit, display.getStrip().Color(0, 150, 0)); // Green color
|
|
value /= 10;
|
|
}
|
|
display.show();
|
|
|
|
counter++;
|
|
if (counter >= pow(10, DIGITS)) counter = 0; // Roll over when max digits reached
|
|
}
|
|
}
|