Ubuntu 24.04 上の Arduino IDE 2.3.2 を使いました。
ボードは、 ESP32 Dev Module です。
プログラム
led_pwm.ino
// ---------------------------------------------------------------------
// led_pwm.ino
//
// Jul/28/2024
// ---------------------------------------------------------------------
#define LED1 32
#define LED2 33
#define LED3 25
#define LED4 26
#define LED5 27
#define LED6 14
#define LED7 12
#define LED8 13
int leds[8] = {LED1,LED2,LED3,LED4,LED5,LED6,LED7,LED8};
int duties[8] = {1,2,4,7,11,16,22,29};
// ---------------------------------------------------------------------
void setup() {
Serial.begin(115200);
for (int it=0; it<8; it++)
{
ledcAttach(leds[it], 1000, 8);
}
}
// ---------------------------------------------------------------------
void loop() {
for (int it=0; it<8; it++)
{
ledcWrite(leds[it], duties[it]);
Serial.print(duties[it]);
Serial.print(" ");
}
Serial.println();
delay(3000);
shift_duties_proc(duties);
}
// ---------------------------------------------------------------------
void shift_duties_proc(int duties[])
{
int duties_last = duties[0];
for (int it=0; it<7; it++)
{
duties[it] = duties[it + 1];
}
duties[7] = duties_last;
}
// ---------------------------------------------------------------------