An LED strip is a flexible circuit board populated with light-emitting diodes (LEDs) that illuminate when powered. These strips are versatile and can be used for various applications, including ambient lighting, accent lighting, task lighting, and even signage. They are popular in both residential and commercial settings due to their ease of installation, low power consumption, and customizable length.
The pin configuration for LED strips can vary depending on the type (single color, RGB, RGBW, etc.). Below is an example of a common RGB LED strip pinout:
Pin Number | Description |
---|---|
1 | 12V or 24V Power |
2 | Red Control |
3 | Green Control |
4 | Blue Control |
5 | Ground (optional) |
#include <Adafruit_NeoPixel.h>
#define LED_PIN 6 // The pin where the LED strip is connected
#define LED_COUNT 30 // Number of LEDs in the strip
// Initialize the LED strip
Adafruit_NeoPixel strip(LED_COUNT, LED_PIN, NEO_GRB + NEO_KHZ800);
void setup() {
strip.begin(); // Initialize the strip
strip.show(); // Initialize all pixels to 'off'
}
void loop() {
// Set the first pixel to red color (R, G, B)
strip.setPixelColor(0, strip.Color(255, 0, 0));
strip.show(); // Update the strip with new settings
delay(500); // Wait for half a second
// Turn off the first pixel
strip.setPixelColor(0, strip.Color(0, 0, 0));
strip.show();
delay(500);
}
Note: The above code uses the Adafruit NeoPixel library to control an RGB LED strip connected to an Arduino UNO. Ensure that the LED_PIN
and LED_COUNT
are set to match your specific setup. The strip.Color()
function takes three arguments corresponding to the red, green, and blue components of the color, each ranging from 0 to 255.