I am trying to create a colour cycle on a ring of LED's, this is my first time using FastLED library can anyone help because currently when I switch t the cycle case, all the led's go static blue
#include "FastLED.h"
#define NUM_LEDS 7
#define DATA_PIN 6
CRGB leds[NUM_LEDS];
const int buttonPin = 2;
int currentcolour = 0;
void setup() {
// put your setup code here, to run once:
FastLED.addLeds<WS2812, DATA_PIN>(leds, NUM_LEDS);
pinMode(buttonPin, INPUT_PULLUP);
}
void loop() {
// put your main code here, to run repeatedly:
int buttonState = digitalRead(buttonPin);
if (buttonState == LOW){
currentcolour ++;
if (currentcolour > 7){
currentcolour = 0;
}
}
for (int i = 0; i < 8; i++) {
switch (currentcolour) {
case 0:
//off
leds[0] = CRGB::Black;
leds[1] = CRGB::Black;
leds[2] = CRGB::Black;
leds[3] = CRGB::Black;
leds[4] = CRGB::Black;
leds[5] = CRGB::Black;
leds[6] = CRGB::Black;
break;
case 1:
//cycle
leds[0] = RainbowColors_p;
leds[1] = RainbowColors_p;
leds[2] = RainbowColors_p;
leds[3] = RainbowColors_p;
leds[4] = RainbowColors_p;
leds[5] = RainbowColors_p;
leds[6] = RainbowColors_p;
FastLED.show();
break;
case 2:
//red
leds[0] = CRGB::Red;
leds[1] = CRGB::Red;
leds[2] = CRGB::Red;
leds[3] = CRGB::Red;
leds[4] = CRGB::Red;
leds[5] = CRGB::Red;
leds[6] = CRGB::Red;
break;
case 3:
leds[0] = CRGB::Green;
leds[1] = CRGB::Green;
leds[2] = CRGB::Green;
leds[3] = CRGB::Green;
leds[4] = CRGB::Green;
leds[5] = CRGB::Green;
leds[6] = CRGB::Green;
break;
case 4:
leds[0] = CRGB::Blue;
leds[1] = CRGB::Blue;
leds[2] = CRGB::Blue;
leds[3] = CRGB::Blue;
leds[4] = CRGB::Blue;
leds[5] = CRGB::Blue;
leds[6] = CRGB::Blue;
break;
case 5:
leds[0] = CRGB::Yellow;
leds[1] = CRGB::Yellow;
leds[2] = CRGB::Yellow;
leds[3] = CRGB::Yellow;
leds[4] = CRGB::Yellow;
leds[5] = CRGB::Yellow;
leds[6] = CRGB::Yellow;
break;
case 6:
leds[0] = CRGB::Magenta;
leds[1] = CRGB::Magenta;
leds[2] = CRGB::Magenta;
leds[3] = CRGB::Magenta;
leds[4] = CRGB::Magenta;
leds[5] = CRGB::Magenta;
leds[6] = CRGB::Magenta;
break;
case 7:
leds[0] = CRGB::Cyan;
leds[1] = CRGB::Cyan;
leds[2] = CRGB::Cyan;
leds[3] = CRGB::Cyan;
leds[4] = CRGB::Cyan;
leds[5] = CRGB::Cyan;
leds[6] = CRGB::Cyan;
break;
}
}
FastLED.show();
delay(250);
}