#include <Adafruit_NeoPixel.h>
#include "Switch.h"
#include <DmxSimple.h>
#define N 5
const byte button1pin=0;
const byte button2pin=1;
const byte button3pin=2;
const byte button4pin=3;
const byte button5pin=4;

Switch button1 = Switch(button1pin,INPUT_PULLUP);
Switch button2 = Switch(button2pin,INPUT_PULLUP);
Switch button3 = Switch(button3pin,INPUT_PULLUP);
Switch button4 = Switch(button4pin,INPUT_PULLUP);
Switch button5 = Switch(button5pin,INPUT_PULLUP);



#define PIXEL_COUNT 7 // On définit le nombre de LED compris sur le Ruban de LED soit 150 pour le ruban de 5m50
#define PIXEL_PIN 6
Adafruit_NeoPixel strip = Adafruit_NeoPixel(PIXEL_COUNT, PIXEL_PIN, NEO_GRB + NEO_KHZ800); // Paramètre l'objet strip qui correspond à toute les LED du ruban

void setup() {
   
    DmxSimple.usePin(5);
    DmxSimple.write(1,50);
 

strip.begin(); // Lance la connection
strip.show(); // Initialise toute les led à 'off'
Serial.begin(9600);

strip.setBrightness(100);


}
int RED[3] = {255, 0, 0}; // Couleur Rouge
int GREEN[3] = {0, 255, 0}; // Couleur Verte
 int CYAN[3] = {0, 255, 255}; // Couleur Cyan
int YELLOW[3] = {255, 125, 0}; // Couleur Jaune
int ORANGE[3] = {255, 40, 0}; // Couleur Orange
int PURPLE[3] = {255, 0 , 255}; // Couleur Violette
int PINK[3] = {255, 0, 100}; // Couleur Rose
int BLUE[3] = {0, 0, 255}; // Couleur Bleu
int WHITE[3] = {255, 255, 255}; // Couleur Blanche
int OFF[3] = {0, 0, 0}; // Éteint

void allLeds(int COLOR[])
{
for(int i = 0 ; i < PIXEL_COUNT ; i++)
{
strip.setPixelColor(i, COLOR[0], COLOR[1], COLOR[2]);
}
strip.show();
}

void loop() {
  int i;
  button5.poll();
  if(button5.on()){
button1.poll();
if (button1.switched()) {allLeds(RED);
DmxSimple.write(2,255);
DmxSimple.write(3,0);
DmxSimple.write(4,0);}
button2.poll();
if (button2.switched()) {allLeds(GREEN);
DmxSimple.write(2,0);
DmxSimple.write(3,255);
DmxSimple.write(4,0);}
button3.poll();
if (button3.switched()) {allLeds(PURPLE);
DmxSimple.write(2,255);
DmxSimple.write(3,0);
DmxSimple.write(4,255);}
button4.poll();
if (button4.switched()) {allLeds(CYAN);
DmxSimple.write(2,0);
DmxSimple.write(3,255);
DmxSimple.write(4,255);}
  }else {
    button1.poll();
if (button1.switched()) {allLeds(PINK);
DmxSimple.write(2,255);
DmxSimple.write(3,0);
DmxSimple.write(4,100);}
button2.poll();
if (button2.switched()) {allLeds(YELLOW);
DmxSimple.write(2,255);
DmxSimple.write(3,125);
DmxSimple.write(4,0);}
button3.poll();
if (button3.switched()){ allLeds(WHITE);
DmxSimple.write(2,255);
DmxSimple.write(3,255);
DmxSimple.write(4,255);}
button4.poll();
if (button4.switched()) {allLeds(BLUE);
DmxSimple.write(2,0);
DmxSimple.write(3,0);
DmxSimple.write(4,255);}
  }
   
 

  

}
