#include <FastLED.h>
#define LED_PIN 6
#define NUM_LEDS 32
#define BRIGHTNESS 150
CRGB leds[NUM_LEDS];
const int Riopin1 = 2; // the number of the First RIO DIO pin (Cone - Orange)
const int Riopin2 = 3; // the number of the Second RIO DIO pin (Cube - Purple)
const int Riopin3 = 4; // the number of the Third RIO DIO pin (Intaking Cone - Blinking Orange)
const int Riopin4 = 5; // the numver of the Forth RIO DIO pin (Intaking Cube - Blinking Purple)
// by default the case is 1 to signify green
int stateCase = 1;
void setup() {
// initialize the LED pin as an output:
pinMode(Riopin1, INPUT);
pinMode(Riopin2, INPUT);
pinMode(Riopin3, INPUT);
pinMode(Riopin4, INPUT);
pinMode(8, OUTPUT);
pinMode(9, OUTPUT);
pinMode(10, OUTPUT);
pinMode(11, OUTPUT);
FastLED.addLeds<WS2812, LED_PIN, GRB>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
// state function
void getState(){
int tmpCase;
if (digitalRead(Riopin1) == HIGH) {
tmpCase = 1; //Orange
}
else if (digitalRead(Riopin2) == HIGH) {
tmpCase = 2; //Purple
}
else if (digitalRead(Riopin3) == HIGH) {
tmpCase = 3; //Blinking Orange or yellow
}
else if (digitalRead(Riopin4) == HIGH) {
tmpCase = 4; //Blinking Purple or pink
}
stateCase = tmpCase;
}
void loop() {
getState();
switch (stateCase){
case 1: {
for (int i = 0; i <= NUM_LEDS; i++) {
leds[i] = CRGB(231, 91, 5);
FastLED.show();
}
} break;
case 2: {
for (int i = 0; i <= NUM_LEDS; i++) {
leds[i] = CRGB(67, 2, 64);
FastLED.show();
}
} break;
case 3: {
for (int i = 0; i <= NUM_LEDS; i++) {
leds[i] = CRGB(241, 237, 3);
FastLED.show();
}
} break;
case 4: {
for (int i = 0; i <= NUM_LEDS; i++) {
leds[i] = CRGB(221, 45, 160);
FastLED.show();
}
} break;
}
}