Connecting RGB LED tape to Arduino UNO (Lesson #1)

In this tutorial we will connect the LED strip with 8 RGB LEDs to the Arduino Uno board.

To control the color of individual LEDs, we use the NeoPixel library from Adafruit. Let’s start!

Necessary equipment

For this project you will need:

  • Arduino Uno Board
  • RGB LED tape
  • 3 connectors
  • Circuit board (breadboard)

Wiring diagram

Everything is connected quite simply. Look at the wiring diagram below.

Sketch for Arduino

The code for the Arduino is shown below. You can copy or download the code.

// connect library
#include <Adafruit_NeoPixel.h>

// declare constants
const int dinPin = 4; // Led tape control pin on 4 pin Arduino
const int numOfLeds = 8; // Number of LEDs

Adafruit_NeoPixel pixels = Adafruit_NeoPixel(numOfLeds, dinPin, NEO_GRB + NEO_KHZ800);

// Color in RGB values, from 0,0,0 to 255,255,255
// example, white = (255,255,255), red = (255,0,0);

int red = 255; // value from 0 (LED is off) to 255().
int green = 0;
int blue = 0;

void setup() {
pixels.begin(); // NeoPixel library initialization
pixels.setBrightness(80); // Brightness value from 0 to 100%
}

void loop() {
// For the NeoPixels kit, the first NeoPixel is 0, the second = 1, up to the maximum number of LEDs minus 1, since we start the countdown from 0
for(int i=0;i<numOfLeds;i++){
pixels.setPixelColor(i, pixels.Color(red,green,blue));
pixels.show(); // We send the updated pixel color value
delay(1000); // Delay before changing colors
}
}

To change the color of the LEDs, change the values in lines 16 and 18 – see comments.

The brightness of the LEDs is changed in line 23 using the method “pixels.setBrightness” (the value is in the range from 0 to 100) “.

Delay time varies on line 32 – see comment.

Conclusion

That’s all! We hope you have successfully completed this small project and connected the LED RGB ribbon to the Arduino.