Do you know those cheap LED strips?

These are often called "analog" LED strips because you cannot control each pixel individually like you do with "digital" strips.


Today we want to drive them using our Arduino board.



Hardware

  • Arduino Board
  • MOSFET
  • White LED strip

As MOSFET i have used I have used the IRF520 that comes with the Arduino starter kit but you can use any general purpose MOSFET (for example the popular STP16NF06).

Schematic









Code


#define PIN 11      // control pin
#define DELAY 10 // 20ms internal delay; increase for slower fades

void setup() {
pinMode(PIN, OUTPUT);
}

void loop() {
// fade in
for(int i=0; i<255; i++) {
analogWrite(PIN, i);
delay(DELAY);
}

// fade out
for(int i=0; i<255; i++) {
analogWrite(PIN, 255-i);
delay(DELAY);
}
}

This is the code if you prefer a "strobo effect".

#define PIN 11      // control pin
#define DELAY 20 // 20ms internal delay; increase for slower pulse

void setup() {
pinMode(PIN, OUTPUT);
}

void loop() {
digitalWrite(PIN, HIGH); // turn on
delay(DELAY); // wait few milliseconds
digitalWrite(PIN, LOW); // turn off
delay(DELAY*10); // wait some more time
}


References


Dimming a 12V LED Strip With an Arduino
RGB LED Strips
RGB Led Strip Controlled by an Arduino


Post a Comment