Un trefle lumineux avec arduino et librairie fast led Code crée grace a Chat Gpt et mistral.
#include <FastLED.h> #define NUM_LEDS 70 #define DATA_PIN 5 CRGB leds[NUM_LEDS]; void setup() { FastLED.addLeds<WS2811, DATA_PIN, GRB>(leds, NUM_LEDS); FastLED.clear(); } int ledcoeur[] = { 54 }; int ledcercle1[] = { 50, 53, 56, 55 }; int ledcercle2[] = { 51, 52, 18, 17, 0, 1, 35, 34 }; int ledcontour[] = { 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 48, 47, 46, 45, 44, 43, 42, 41, 40, 39, 38, 3 }; int ledcirclehigh[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16 }; int ledcirclelow[] = { 52, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 51 }; int ledcircleleft[] = { 35, 2, 3, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 32, 33, 34 }; int ledcircleright[] = { 18, 19, 20, 69, 68, 67, 66, 65, 64, 63, 62, 61, 60, 59, 15, 16, 17 }; int ledhuitvertical[] = { 54, 55, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 56, 54, 50, 33, 32, 31, 30, 29, 28, 27, 26, 25, 24, 23, 22, 21, 20, 19, 53, 54 }; int ledinfinihorisontal[] = { 54, 56, 16, 15, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 20, 19, 53, 54, 55, 2, 3, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 32, 33, 50, 54 }; int ledsall[] = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 }; void loop() { zledcoeur(1, 1, 500 / 2); zledcercle1(1, 1, 500 / 3); zledcercle2(1, 1, 500 / 3); zledcontour(1, 1, 500 / 6); zledcirclehigh(1, 1, 500 / 6); zledcirclelow(1, 1, 500 / 6); zledcircleleft(1, 1, 500 / 6); zledcircleright(1, 1, 500 / 6); zledhuitvertical(1, 1, 500 / 6); zledinfinihorisontal(1, 1, 500 / 6); // Clignoter toutes les LEDs fill_solid(leds, NUM_LEDS, CRGB::Red); // Allumer toutes les LED en blanc FastLED.show(); // Afficher les LED delay(500); // Attendre 500 millisecondes fill_solid(leds, NUM_LEDS, CRGB::Black); // Éteindre toutes les LED FastLED.show(); // Afficher les LED delay(500); // Attendre 500 millisecondes fill_solid(leds, NUM_LEDS, CRGB::Red); // Allumer toutes les LED en blanc FastLED.show(); // Afficher les LED delay(500); // Attendre 500 millisecondes fill_solid(leds, NUM_LEDS, CRGB::Black); // Éteindre toutes les LED FastLED.show(); // Afficher les LED delay(500); // Attendre 500 millisecondes fill_solid(leds, NUM_LEDS, CRGB::Red); // Allumer toutes les LED en blanc FastLED.show(); // Afficher les LED delay(500); // Attendre 500 millisecondes fill_solid(leds, NUM_LEDS, CRGB::Black); // Éteindre toutes les LED FastLED.show(); // Afficher les LED delay(500); // Attendre 500 millisecondes } void showGradient(int *ledArray, int size, int howfast, uint8_t startHue, uint8_t endHue) { for (int i = 0; i < size; ++i) { uint8_t hue = map(i, 0, size - 1, startHue, endHue); leds[ledArray[i]] = CHSV(hue, 255, 255); FastLED.show(); delay(howfast); fadeToBlackBy(leds, NUM_LEDS, 64); // Add fade effect FastLED.show(); } FastLED.clear(true); } void zledcoeur(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcoeur, sizeof(ledcoeur) / sizeof(int), howfast, 0, 255); } } void zledcercle1(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcercle1, sizeof(ledcercle1) / sizeof(int), howfast, 0, 255); } } void zledcercle2(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcercle2, sizeof(ledcercle2) / sizeof(int), howfast, 0, 255); } } void zledcontour(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcontour, sizeof(ledcontour) / sizeof(int), howfast, 0, 255); } } void zledcirclehigh(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcirclehigh, sizeof(ledcirclehigh) / sizeof(int), howfast, 0, 255); } } void zledcirclelow(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcirclelow, sizeof(ledcirclelow) / sizeof(int), howfast, 0, 255); } } void zledcircleleft(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcircleleft, sizeof(ledcircleleft) / sizeof(int), howfast, 0, 255); } } void zledcircleright(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledcircleright, sizeof(ledcircleright) / sizeof(int), howfast, 0, 255); } } void zledhuitvertical(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledhuitvertical, sizeof(ledhuitvertical) / sizeof(int), howfast, 0, 255); } } void zledinfinihorisontal(int color, int turn, int howfast) { for (int T = 1; T <= turn; T++) { showGradient(ledinfinihorisontal, sizeof(ledinfinihorisontal) / sizeof(int), howfast, 0, 255); } }