#include <FastLED.h>
#define NUM_LEDS 24
#define DATA_PIN 10 //How boring and obvious!
#define COLOR_ORDER GRB //Green (G), Red (R), Blue (B)
#define CHIPSET WS2812B
#define BRIGHTNESS 250
#define VOLTS 5
#define MAX_AMPS 3600 //value in milliamps
// Define the array of leds
CRGB leds[NUM_LEDS];
int pinA = 2;
int pinB = 3;
int pinC = 4;
int pinD = 5;
int pinE = 6;
int pinF = 7;
int pinG = 8;
int i = 0;
int j = 0;
int Arduino_Pins[7] = {pinA, pinB, pinC, pinD, pinE, pinF, pinG};
int Segment_Pins[10][7] = {{0, 0, 0, 0, 0, 0, 1}, // 0
{1, 0, 0, 1, 1, 1, 1}, // 1
{0, 0, 1, 0, 0, 1, 0}, // 2
{0, 0, 0, 0, 1, 1, 0}, // 3
{1, 0, 0, 1, 1, 0, 0}, // 4
{0, 1, 0, 0, 1, 0, 0}, // 5
{0, 1, 0, 0, 0, 0, 0}, // 6
{0, 0, 0, 1, 1, 1, 1}, // 7
{0, 0, 0, 0, 0, 0, 0}, // 8
{0, 0, 0, 0, 1, 0, 0}, // 9
};
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<CHIPSET,DATA_PIN,COLOR_ORDER>(leds,NUM_LEDS);
FastLED.setMaxPowerInVoltsAndMilliamps(VOLTS,MAX_AMPS);
FastLED.setBrightness(BRIGHTNESS);
FastLED.clear();
FastLED.show();
pinMode(pinA, OUTPUT);
pinMode(pinB, OUTPUT);
pinMode(pinC, OUTPUT);
pinMode(pinD, OUTPUT);
pinMode(pinE, OUTPUT);
pinMode(pinF, OUTPUT);
pinMode(pinG, OUTPUT);
pinMode(12, INPUT_PULLUP);
pinMode(11, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int delay_ms;
for (j = 0; j<7; j++)
{
digitalWrite(Arduino_Pins[j], Segment_Pins[i][j]);
}
if(digitalRead(12)==0)
{
while(digitalRead(12)==0)
{
}
i++; // i = i + 1;
}
if(i == 10)
{
i = 0;
}
delay(200);
int afficheur = i;
int play = digitalRead(11);
CRGB color;
if (play == LOW) {
digitalRead(afficheur);
if (afficheur == 1)
{color = CRGB::Red;
delay_ms = 2500;
}
else if (afficheur == 2)
{color = CRGB::Orange;
delay_ms = 5000;
}
else if (afficheur == 3)
{color = CRGB::Yellow;
delay_ms = 7500;
}
else if (afficheur == 4)
{color =CRGB::Blue;
delay_ms = 10000;
}
else if (afficheur == 5)
{color =CRGB::Green;
delay_ms = 12500;
}
else if (afficheur == 6)
{color =CRGB::CRGB::Indigo;
delay_ms = 15000;
}
else if (afficheur == 7)
{color =CRGB::Violet;
delay_ms = 17500;
}
else if (afficheur == 8)
{color = CRGB::Brown;
delay_ms = 20000;
}
else if (afficheur == 9)
{color = CRGB::White;
delay_ms = 22500;
}
else if (afficheur == 0)
{ color = CRGB::Black;
}
fill_solid(leds, NUM_LEDS, color);
FastLED.setBrightness(BRIGHTNESS);
for (int i = 0; i<=24; i++)
{
FastLED.show();
leds[i] = CRGB::Black;
delay(delay_ms);
}
int rep = 0;
while(rep<3) {
rep++;
for (int i=0; i<NUM_LEDS; i++) {
leds[i] = color;
}
for (int i=0; i<BRIGHTNESS; i++) {
FastLED.setBrightness(i);
FastLED.show();
delay(1);
}
for (int i=BRIGHTNESS; i>=0; i--) {
FastLED.setBrightness(i);
FastLED.show();
delay(1);
}
}
}
}