first upload

This commit is contained in:
ghassan committed 2025-07-13 15:44:13 +03:00
commit 64c8e88536
8 files changed
+275

No files matched your search

+23
View File
@@ -0,0 +1,23 @@
#include "SevenSegmentNeoPixel.h"
#define DIGITS 4
#define PIXELS_PER_SEGMENT 7
#define PIN 0
SevenSegmentNeoPixel display(DIGITS, PIXELS_PER_SEGMENT, PIN);
void setup() {
display.begin();
display.setBrightness(50);
}
void loop() {
for (uint8_t d = 0; d < DIGITS; ++d) {
display.setDigit(d, d, display.getStrip().Color(255, 0, 0)); // Show digit index in red
}
display.show();
delay(1000);
display.clear();
display.show();
delay(500);
}
+35
View File
@@ -0,0 +1,35 @@
#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
}
}
@@ -0,0 +1,67 @@
#include <SevenSegmentNeoPixel.h>
#define DIGITS 1
#define PIXELS_PER_SEGMENT 7
#define PIN 0
SevenSegmentNeoPixel display(DIGITS, PIXELS_PER_SEGMENT, PIN);
uint32_t colorWheel(byte pos) {
pos = 255 - pos;
if (pos < 85) {
return display.getStrip().Color(255 - pos * 3, 0, pos * 3);
}
if (pos < 170) {
pos -= 85;
return display.getStrip().Color(0, pos * 3, 255 - pos * 3);
}
pos -= 170;
return display.getStrip().Color(pos * 3, 255 - pos * 3, 0);
}
void setup() {
display.begin();
display.setBrightness(50);
}
void loop() {
static unsigned long lastAnim = 0;
static unsigned long lastCount = 0;
static unsigned long counter = 0;
static uint16_t rainbowOffset = 0;
unsigned long now = millis();
// Animate rainbow every 50ms
if (now - lastAnim >= 50) {
lastAnim = now;
display.clear();
unsigned long value = counter;
for (int d = DIGITS - 1; d >= 0; d--) {
uint8_t digit = value % 10;
value /= 10;
const uint8_t* segPattern = SevenSegmentNeoPixel::getSegmentPattern(digit);
for (uint8_t seg = 0; seg < 7; seg++) {
if (segPattern && segPattern[seg]) {
for (uint8_t px = 0; px < PIXELS_PER_SEGMENT; px++) {
uint16_t globalPixel = d * 7 * PIXELS_PER_SEGMENT + seg * PIXELS_PER_SEGMENT + px;
uint8_t colorPos = (globalPixel * 256 / (DIGITS * 7 * PIXELS_PER_SEGMENT) + rainbowOffset) & 0xFF;
uint32_t color = colorWheel(colorPos);
display.getStrip().setPixelColor(globalPixel, color);
}
}
}
}
display.show();
rainbowOffset += 4; // Wave speed
}
// Increment counter every 1000ms (1 second)
if (now - lastCount >= 1000) {
lastCount = now;
counter++;
if (counter >= pow(10, DIGITS)) counter = 0;
}
}