// Include the Adafruit NeoPixel library for LED strip control
#include <Adafruit_NeoPixel.h>
// Define hardware connections and configuration
#define MOSFET_PIN 5 // Digital pin for MOSFET control
#define LED_PIN 9 // Digital pin for LED data signal
#define NUM_LEDS 32 // Number of LEDs in the strip
#define BRIGHTNESS 255 // LED brightness (0-255) <<<< 30 was too low in the sim
// Initialize NeoPixel strip object
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, LED_PIN, NEO_GRB + NEO_KHZ800);
// Define colors once
uint32_t red = strip.Color(255, 0, 0);
uint32_t green = strip.Color(0, 255, 0);
uint32_t blue = strip.Color(0, 0, 255);
uint32_t off = strip.Color(0, 0, 0);
void setup() {
Serial.begin(115200);
// Configure MOSFET control pin
pinMode(MOSFET_PIN, OUTPUT);
digitalWrite(MOSFET_PIN, LOW); // Start with power off
// Initialize LED strip
strip.begin();
strip.setBrightness(BRIGHTNESS);
strip.show(); // Initialize all LEDs to 'off'
Serial.println("Ready");
delay(1000);
}
void loop() {
// Enable power to LED strip via MOSFET
digitalWrite(MOSFET_PIN, HIGH);
delay(50); // Allow power to stabilize
// Cycle through colors using predefined values
strip.fill(red);
strip.show();
Serial.println("Red");
delay(1000);
strip.fill(green);
strip.show();
Serial.println("Green");
delay(1000);
strip.fill(blue);
strip.show();
Serial.println("Blue");
delay(1000);
strip.fill(off);
strip.show();
Serial.println("Black");
delay(1000);
// Optional: Disable power via MOSFET
// digitalWrite(MOSFET_PIN, LOW);
// delay(1000);
}