mdraber
Published © GPL3+

How to control 32x8 WS2812 LED Matrix with Arduino PART1

This tutorial shows you how to connect the matrix to Arduino and run few simplest programs

BeginnerProtip1 hour2,971
How to control 32x8 WS2812 LED Matrix with Arduino PART1

Things used in this project

Hardware components

Arduino Nano R3
Arduino Nano R3
×1
32x8 WS2812B Led Matrix
×1

Story

Read more

Code

Litting the first and last led in the matrix (white)

Arduino
#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 12
CRGB leds[NUM_LEDS];

void setup() {   
 FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
 FastLED.setBrightness(150);
}
 
void loop() { 
  leds[0]=CRGB::White;
  leds[255]=CRGB::White;
  FastLED.show();
}

Lighting all LEDs one at a time

Arduino
#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 12
CRGB leds[NUM_LEDS];

void setup() {   
 FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
 FastLED.setBrightness(150);
}

void loop() {
 for (int i=0;i<256;i++) {
   if(i>0) leds[i-1]=CRGB::Black;
   leds[i]=CRGB::White;
   FastLED.show();
   delay(20);
 }
}

Blue Red Green snake going through all leds in the matrix

Arduino
#include <FastLED.h>
#define NUM_LEDS 256
#define DATA_PIN 12
CRGB leds[NUM_LEDS];

void setup() {   
 FastLED.addLeds<WS2812,DATA_PIN,RGB>(leds,NUM_LEDS);
 FastLED.setBrightness(150);

void loop() {
 for (int i=0;i<256;i++) {
   if(i>0) leds[i-1]=CRGB::Black;
   leds[i]=CRGB::Blue;
   if (i<255) leds[i+1]=CRGB::Red;
   if (i<254) leds[i+2]=CRGB::Green;
   FastLED.show();
   delay(70);
 }
}

Credits

mdraber

mdraber

49 projects • 67 followers

Comments