Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <Adafruit_NeoPixel.h>
- #define LED_PIN 0 // or any other PWM capable pin
- #define Nbre_LEDs 25
- #define OUT1 1
- #define BUZZER 2
- #define BRIGHTNESS 40 // [1..255]
- #define pause 5 // in milliseconds
- Adafruit_NeoPixel Matrice = Adafruit_NeoPixel(Nbre_LEDs, LED_PIN, NEO_RGB + NEO_KHZ800);
- void setup()
- {
- //delay(500); // Délai pour rechercher à combattre les aléas suite à une secousse trop énergique (non utilisé)
- pinMode (OUT1, OUTPUT);
- pinMode (BUZZER, OUTPUT);
- digitalWrite (OUT1, HIGH);
- digitalWrite (BUZZER, LOW);
- delay(20);
- Matrice.begin();
- digitalWrite (BUZZER, HIGH); // Beep pour confirmer le démarrage
- delay(10);
- digitalWrite (BUZZER, LOW);
- delay(10);
- digitalWrite (BUZZER, HIGH);
- delay(10);
- digitalWrite (BUZZER, LOW);
- delay(10);
- }
- void loop()
- {
- delay(1000); // Délai pour rechercher à combattre les aléas suite à une secousse trop énergique
- //pinMode (OUT1, OUTPUT); // Repassage en mode OUT (au cas où la boucle devait tourner)
- for (byte i = 0; i < Nbre_LEDs; i++) {
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0)); // début animation de la matrice 25 LEDs
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, BRIGHTNESS, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, BRIGHTNESS, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(BRIGHTNESS, 0, BRIGHTNESS));
- Matrice.show();
- delay(pause);
- Matrice.setPixelColor(i, Matrice.Color(0, 0, 0));
- Matrice.show();
- delay(pause);
- }
- Matrice.clear (); // Fin de l'animation, on efface tout et on affiche
- Matrice.show();
- digitalWrite (BUZZER, HIGH); // Beep - Beep - Beep pour avertir que l'on va couper couper l'alimentation
- delay(100);
- digitalWrite (BUZZER, LOW);
- delay(100);
- digitalWrite (BUZZER, HIGH);
- delay(100);
- digitalWrite (BUZZER, LOW);
- delay(100);
- digitalWrite (BUZZER, HIGH);
- delay(100);
- digitalWrite (BUZZER, LOW);
- delay(700);
- digitalWrite (OUT1, LOW); // Front descendant pour désarmer l'alimentation
- //pinMode (OUT1, INPUT_PULLUP); // Mise en haute impédance : j'ai supprimé cette mise à haute impédance car elle perturbait le blocage du transistor ballast lorsque le montage aval comporte des capas chimiques
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement