meta données pour cette page
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédente | |||
neopixels_-_exemple_de_fonctions_pour_allumer_et_eteindre_les_neopixels [2015/04/08 10:07] – Alexandre Castonguay | neopixels_-_exemple_de_fonctions_pour_allumer_et_eteindre_les_neopixels [2015/04/08 15:01] (Version actuelle) – Alexandre Castonguay | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
<sxh java> | <sxh java> | ||
- | |||
// Par Alexandre Castonguay, basé sur le code de " | // Par Alexandre Castonguay, basé sur le code de " | ||
- | // released under the GPLv3 license to match the rest of the AdaFruit NeoPixel library | + | // publié sous la licence |
// Utilisez les appels de fonction " | // Utilisez les appels de fonction " | ||
+ | |||
#include < | #include < | ||
#include < | #include < | ||
+ | |||
+ | // Sur quelle broche (PIN) de l' | ||
- | // Which pin on the Arduino is connected to the NeoPixels? | + | #define PIN 6 |
- | // On a Trinket or Gemma we suggest changing this to 1 | + | |
- | # | + | // Combien de néopixels sont connectés sur l' |
- | #define PIN2 6 | + | # |
+ | |||
+ | // Lorsque nous configurons la bibliothèque néopixel , nous devons déclarer le nombre de néopixels et de | ||
+ | // broches à utiliser pour envoyer des signaux. | ||
+ | // Notez que pour les plus vieilles versions de néopixels, vous pourriez avoir besoin de changer le troisième paramètre - voir " | ||
+ | // Allez voir les exemples pour plus d' | ||
+ | |||
+ | Adafruit_NeoPixel pixels = Adafruit_NeoPixel(NUMPIXELS, | ||
+ | |||
+ | |||
+ | void setup() { | ||
- | // How many NeoPixels are attached to the Arduino? | + | |
- | #define NUMPIXELS1 | + | |
- | #define NUMPIXELS2 | + | |
- | + | ||
- | // 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, | + | |
- | Adafruit_NeoPixel pixels2 = Adafruit_NeoPixel(NUMPIXELS2, | + | |
- | + | ||
- | + | ||
- | void setup() { | + | |
- | pixels1.begin(); // This initializes the NeoPixel library. | + | |
- | pixels2.begin(); | + | |
Serial.begin(9600); | Serial.begin(9600); | ||
} | } | ||
+ | |||
void loop() { | 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. | + | // Pour un jeu de néopixels le premier néopixel est 0, le deuxième est 1, et ainsi de suite |
- | | + | |
- | pixels2.show(); | + | |
- | + | for(int i=0;i<NUMPIXELS; | |
- | for(int i=NUMPIXELS1; | + | |
- | Serial.print(" | + | |
- | Serial.println(i); | + | |
- | | + | |
- | | + | |
- | } | + | |
- | | + | |
- | for(int i=0;i<NUMPIXELS2;i++){ | + | |
- | | + | |
| | ||
- | allumer2(i,2); | + | allumer(i, |
- | | + | |
} | } | ||
- | |||
| | ||
- | /* | + | |
- | for(int i=0;i<NUMPIXELS2;i++){ | + | |
eteindre(i, | eteindre(i, | ||
- | delay(20); | + | delay(20); |
- | } | + | } |
- | */ | + | |
- | + | ||
- | | + | |
} | } | ||
- | | + | |
for(int fi=0; | for(int fi=0; | ||
- | pixels1.setPixelColor(DEL, | + | pixels.setPixelColor(DEL, |
- | pixels1.show(); | + | pixels.show(); |
- | | + | |
} | } | ||
} | } | ||
- | + | | |
- | + | ||
- | void allumer2(int DEL,int delai){ // le premier argument est la lumiere et le second est l' | + | |
- | for(int fi=0; | + | |
- | | + | |
- | | + | |
- | | + | |
- | } | + | |
- | } | + | |
- | + | ||
void eteindre(int DEL,int delai){ // le premier argument est la lumiere et le second est l' | void eteindre(int DEL,int delai){ // le premier argument est la lumiere et le second est l' | ||
for(int fo=255; | for(int fo=255; | ||
Ligne 83: | Ligne 59: | ||
Serial.print(" | Serial.print(" | ||
Serial.println(fo); | Serial.println(fo); | ||
- | | + | |
- | pixels2.setPixelColor(DEL, | + | pixels.setPixelColor(DEL, |
- | pixels2.show(); | + | pixels.show(); |
| | ||
} | } | ||
} | } | ||
- | |||
</ | </ |