#include <driver/ledc.h>
// Define LED pins (replace with your actual pin numbers)
const int led_pins[] = {2,3, 4, 5, 6,7,8, 9, 10,11,12,13,14,15,16,17,18,21,33,34,35};
const int num_leds = 22;
// LEDC channel configuration
const int ledc_channel = 0;
const int freq = 0.005; // 5 kHz PWM frequency
const int resolution = 32; // 32-bit resolution
void setup() {
for (int i = 0; i < num_leds; i++) {
pinMode(led_pins[i], OUTPUT);
}
// Configure LEDC channel
ledcSetup(ledc_channel, freq, resolution);
// Attach LED pins to LEDC channel
for (int i = 0; i < num_leds; i++) {
ledcAttachPin(led_pins[i], ledc_channel);
}
//delay(1000);
}
void loop() {
for (int i = 0; i < num_leds; i++) {
ledcWrite(ledc_channel, 255); // Turn on LED
delay(500); // Delay for visibility
ledcWrite(ledc_channel, 0); // Turn off LED
}
for (int i = num_leds - 1; i >= 0; i--) {
ledcWrite(ledc_channel, 255); // Turn on LED
delay(500); // Delay for visibility
ledcWrite(ledc_channel, 0); // Turn off LED
}
}Loading
wemos-s2-mini
wemos-s2-mini