Bonjour,
pour commencer je suis débutant, maintenant voici mon problème; j'ai des neopixels que je veux faire passer de éteinte a r/v/b et pouvoir revenir en arrière, mais voila que tout mes tentative sont des échecs. je vais vous donner mon code et dite moi comment faire svp pour ajouter un bouton down
merci BCp de m'aider
const int buttonUpPin = 2;
const int buttonDownPin = 7;
// Variables will change:
int buttonPushCounter = 0;
int buttonState = 0;
int lastButtonState = 0;
int ColorMode = 0;
#include <Adafruit_NeoPixel.h>
#define PIN 1//This is the data pin connected to arrow on first NeoPixel
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
// NEO_KHZ800 800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
// NEO_KHZ400 400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
// NEO_GRB Pixels are wired for GRB bitstream (most NeoPixel products)
// NEO_RGB Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(10, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
pinMode(buttonUpPin, INPUT);
// initialize serial communication:
// Serial.begin(9600);
strip.begin(); //intialize neopixels
}
void loop() {
buttonState = digitalRead(buttonUpPin);
if (buttonState != lastButtonState) {
if (buttonState == HIGH) {
buttonPushCounter++;
}
else {
}
}
lastButtonState = buttonState;
ColorMode = buttonPushCounter % 5; //This is performing integer divison and calculating the remainder
if (ColorMode == 0) { // ColorMode 0 is all off
strip.setPixelColor (0,0,0,0); //first neopixel in strip
strip.setPixelColor (1,0,0,0); //second neopixel in strip
strip.setPixelColor (2,0,0,0); //third neopixel in strip
strip.setPixelColor (3,0,0,0); //fourth neopixel in strip
strip.show (); //this is like hitting send on a text to neopixels but the text tells the lights what to do
} else if (ColorMode == 1){
strip.setPixelColor (0,155,0,0); //first neopixel in strip
strip.setPixelColor (1,155,0,0); //second neopixel in strip
strip.setPixelColor (2,155,0,0); //third neopixel in strip
strip.setPixelColor (3,155,0,0); //fourth neopixel in strip
strip.show (); //this is like hitting send on a text to neopixels but the text tells the lights what to do
} else if (ColorMode == 2){
strip.setPixelColor (0,0,155,0); //first neopixel in strip
strip.setPixelColor (1,0,155,0); //second neopixel in strip
strip.setPixelColor (2,0,155,0); //third neopixel in strip
strip.setPixelColor (3,0,155,0); //fourth neopixel in strip
strip.show (); //this is like hitting send on a text to neopixels but the text tells the lights what to do
}
else if (ColorMode == 3){
strip.setPixelColor (0,0,0,155); //first neopixel in strip
strip.setPixelColor (1,0,0,155); //second neopixel in strip
strip.setPixelColor (2,0,0,155); //third neopixel in strip
strip.setPixelColor (3,0,0,155); //fourth neopixel in strip
strip.show (); //this is like hitting send on a text to neopixels but the text tells the lights what to do
} else if (ColorMode == 4){
strip.setPixelColor (0,0,0,155); //first neopixel in strip
strip.setPixelColor (1,0,0,155); //second neopixel in strip
strip.setPixelColor (2,0,0,155); //third neopixel in strip
strip.setPixelColor (3,0,0,155); //fourth neopixel in strip
strip.setPixelColor (4,0,0,155); //second neopixel in strip
strip.setPixelColor (5,0,0,155); //third neopixel in strip
strip.setPixelColor (6,0,0,155); //fourth neopixel in strip
strip.show (); //this is like hitting send on a text to neopixels but the text tells the lights what to do
}else
delay(1);
}