// Date: 03/12/2025
// Experiment No: 07
// Name: Rajaram Parida
// Redg: 2241016203
// Section: 224101028
//Objective 3
#include <Adafruit_NeoPixel.h>
#define LED_PIN 7
#define NUM_LEDS 10
#define BUTTON_PIN 2
Adafruit_NeoPixel strip(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
int levels[5] = {20, 60, 120, 180, 255};
int indexLevel = 0;
bool lastState = HIGH;
void setup() {
pinMode(BUTTON_PIN, INPUT_PULLUP);
strip.begin();
strip.setBrightness(levels[indexLevel]);
for(int i = 0; i < NUM_LEDS; i++) strip.setPixelColor(i, strip.Color(255, 255, 255));
strip.show();
}
void loop() {
bool state = digitalRead(BUTTON_PIN);
if(state == LOW && lastState == HIGH) {
indexLevel = (indexLevel + 1) % 5;
strip.setBrightness(levels[indexLevel]);
strip.show();
delay(250);
}
lastState = state;
}