meta données pour cette page
Ceci est une ancienne révision du document !
// Par Alexandre Castonguay, basé sur le code de "NeoPixel Ring simple sketch (c) 2013 Shae Erisson"
// released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library
// Utilisez les appels de fonction "allumer(int,int);" et "eteindre(int,int);"
#include <Adafruit_NeoPixel.h>
#include <avr/power.h>
// Which pin on the Arduino is connected to the NeoPixels?
// On a Trinket or Gemma we suggest changing this to 1
#define PIN1 3 // jaune
#define PIN2 6 // vert
// How many NeoPixels are attached to the Arduino?
#define NUMPIXELS1 5 // jaune
#define NUMPIXELS2 5 // vert
// When we setup the NeoPixel library, we tell it how many pixels, and which pin to use to send signals.
// Note that for older NeoPixel strips you might need to change the third parameter--see the strandtest
// example for more information on possible values.
Adafruit_NeoPixel pixels1 = Adafruit_NeoPixel(NUMPIXELS1, PIN1, NEO_GRB + NEO_KHZ800); // jaune
Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS2, PIN2, NEO_GRB + NEO_KHZ800); // vert
void setup() {
pixels1.begin(); // This initializes the NeoPixel library.
pixels2.begin(); // This initializes the NeoPixel library.
Serial.begin(9600);
}
void loop() {
// For a set of NeoPixels the first NeoPixel is 0, second is 1, all the way up to the count of pixels minus one.
pixels1.show();
pixels2.show();
for(int i=NUMPIXELS1;i>=0;i--){
Serial.print("DELS1 : ");
Serial.println(i);
allumer1(i,2);
delay(15); // Delay for a period of time (in milliseconds).
}
for(int i=0;i<NUMPIXELS2;i++){
Serial.print("allume DEL 2: ");
Serial.println(i);
allumer2(i,2);
delay(15); // Delay for a period of time (in milliseconds).
}
/*
for(int i=0;i<NUMPIXELS2;i++){
eteindre(i,5);
delay(20); // Delay for a period of time (in milliseconds).
}
*/
}
void allumer1(int DEL,int delai){ // le premier argument est la lumiere et le second est l'intervalle
for(int fi=0;fi<255;fi++){
pixels1.setPixelColor(DEL, pixels1.Color(fi,fi,fi)); // allume de 0 a 255
pixels1.show();
delay(delai);
}
}
void allumer2(int DEL,int delai){ // le premier argument est la lumiere et le second est l'intervalle
for(int fi=0;fi<255;fi++){
pixels2.setPixelColor(DEL, pixels2.Color(fi,fi,fi)); // allume de 0 a 255
pixels2.show();
delay(delai);
}
}
void eteindre(int DEL,int delai){ // le premier argument est la lumiere et le second est l'intervalle
for(int fo=255;fo>=0;fo--){
Serial.print("eteint DEL: ");
Serial.println(DEL);
Serial.print("avec fondu au noir de valeur : ");
Serial.println(fo);
pixels2.setPixelColor(DEL, pixels2.Color(fo,fo,fo)); // eteint de 255 a 0
pixels2.show();
delay(delai);
}
}