LED strip ws2812b: Difference between revisions

From wikiluntti
Line 4: Line 4:


Each part of the RGB ledd will use at maximum 20mA which gives us 3x20mA = 60mA per pixel. The USB plugged into a computer can provide 500mA of power, and Arduino can supply about 200 mA.  
Each part of the RGB ledd will use at maximum 20mA which gives us 3x20mA = 60mA per pixel. The USB plugged into a computer can provide 500mA of power, and Arduino can supply about 200 mA.  
If powered by USB, there is a 500mA PTC fuse in line from 5V from the PC.
* If powered by USB, there is a 500mA PTC fuse in line from 5V from the PC.
* The 5V pin of the Arduino is not connected through the microcontroller. When you are powering your arduino from USB, the USB interface limits your total power consumption to 500 mA.


Take 8 LED in a row: max 8x60 mA = 480 mA.
Take 8 LED in a row: max 8x60 mA = 480 mA.
https://arduino.stackexchange.com/questions/24545/what-happens-if-i-draw-too-much-current-from-atmega-io-pin/24546#24546
*


== Programming ==
== Programming ==

Revision as of 19:02, 8 November 2024

Introduction

300 LEDs, 5m,

Each part of the RGB ledd will use at maximum 20mA which gives us 3x20mA = 60mA per pixel. The USB plugged into a computer can provide 500mA of power, and Arduino can supply about 200 mA.

  • If powered by USB, there is a 500mA PTC fuse in line from 5V from the PC.
  • The 5V pin of the Arduino is not connected through the microcontroller. When you are powering your arduino from USB, the USB interface limits your total power consumption to 500 mA.

Take 8 LED in a row: max 8x60 mA = 480 mA.

https://arduino.stackexchange.com/questions/24545/what-happens-if-i-draw-too-much-current-from-atmega-io-pin/24546#24546

Programming

Simple code using FastLED package:

#include <FastLED.h>

#define NUM_LEDS 3
#define LED_PIN 5

CRGB leds[NUM_LEDS];

void setup () {
  FastLED.addLeds<WS2812B, LED_PIN, GRB>(leds, NUM_LEDS);
  FastLED.setBrightness(50);
  delay(2000);
}


void loop () {
  for (int i=0; i<NUM_LEDS; i++){
    leds[i] = CRGB::Red;
    FastLED.show();
    delay(500);
    leds[i] = CRGB::Green;
    FastLED.show();
    delay(500);

    leds[i] = CRGB::Black;
    FastLED.show();
 }
}