Thank you for your help. So i did some modifications to the code as per your help. Now my issue is that the second pattern (Rainbow effect) is on for only approximately 100ms. How can I make it stay on this effect for about 5 seconds? My new code is as follows
#include <FastLED.h>
#define DATA_PIN 3
#define NUM_LEDS 32
#define NUM_PATTERN1 4
#define NUM_PATTERN2 1
CRGB leds[NUM_LEDS];
void fadeall() { for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(120); } }
void setup() {
Serial.begin(9600);
Serial.println("resetting");
LEDS.addLeds<WS2812, DATA_PIN, GRB>(leds, NUM_LEDS);
LEDS.setBrightness(200);
}
void pattern1() {
//GERRY MOD
// uint8_t hue = 0;
for (int i = 0; i < NUM_LEDS; i++) {
uint8_t mappedHue = map(i, 0, NUM_LEDS - 1, 1, 250);
leds[i] = CHSV(mappedHue, 255, 255);
FastLED.show();
fadeall();
delay(70);
}
delay(500);
}
void pattern2() {
//GERRY MOD
uint8_t hue = 0;
for (int i = 0; i < NUM_LEDS; i++) {
//leds[i] = CHSV(hue, 255, 255);
leds[i] = CHSV(hue, 255, 255);
}
EVERY_N_MILLISECONDS(125) {
hue--;
}
}
void loop() {
for (int i = 0; i < NUM_PATTERN1; i++) {
pattern1();
}
for (int i = 0; i < NUM_PATTERN2; i++) {
pattern2();
}
}