Page 1 of 1
Forum

Welcome to the Tweaking4All community forums!
When participating, please keep the Forum Rules in mind!

Topics for particular software or systems: Start your topic link with the name of the application or system.
For example “MacOS X – Your question“, or “MS Word – Your Tip or Trick“.

Please note that switching to another language when reading a post will not bring you to the same post, in Dutch, as there is no translation for that post!



how to create a sta...
 
Share:
Notifications
Clear all

[Solved] how to create a static color show using arduino for ws2812b led strip?

4 Posts
2 Users
0 Reactions
6,989 Views
(@askfriends)
New Member
Joined: 9 years ago
Posts: 2
Topic starter  

Hello;

i want to create a static color show for my ws2812b led strip, lets suppose i want only to show red color behind my tv, so how to make sketch? please someone write and share.

thanks


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2791
 

Hi AskFriends,

(see also the Arduino LED effect article)

When using the FastLED library, you could do something like this:

#include "FastLED.h"
#define NUM_LEDS 60 // Number of LEDs in your ELD strip
CRGB leds[NUM_LEDS];
#define PIN 6 // Arduino pin used for LED strip
void setup()
{
  FastLED.addLeds<WS2811, PIN, GRB>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
}
void loop() { 
  for(int i = 0; i < NUM_LEDS; i++ ) {
    leds[Pixel].r = 0x00; // Red
    leds[Pixel].g = 0x00; // Green
    leds[Pixel].b = 0xFF; // Blue
  }
FastLED.show();
}

For AdaFruit NeoPixel library something like this:

#include 
#define PIN 6  // Arduino PIN
#define NUM_LEDS 60 // Number of LEDs in strip
// Parameter 1 = number of pixels in strip
// Parameter 2 = pin number (most are valid)
// Parameter 3 = pixel type flags, add together as needed:
//   NEO_KHZ800  800 KHz bitstream (most NeoPixel products w/WS2812 LEDs)
//   NEO_KHZ400  400 KHz (classic 'v1' (not v2) FLORA pixels, WS2811 drivers)
//   NEO_GRB     Pixels are wired for GRB bitstream (most NeoPixel products)
//   NEO_RGB     Pixels are wired for RGB bitstream (v1 FLORA pixels, not v2)
Adafruit_NeoPixel strip = Adafruit_NeoPixel(NUM_LEDS, PIN, NEO_GRB + NEO_KHZ800);
void setup() {
  strip.begin();
  strip.show(); // Initialize all pixels to 'off'
}
void loop() { 
  for(int i = 0; i < NUM_LEDS; i++ ) {
    strip.setPixelColor(Pixel, strip.Color(0, 0, 0xff));
  }
  strip.show();
}

(Note: updated code, replace red, green and blue with numbers)

Hope this helps 


   
ReplyQuote
(@askfriends)
New Member
Joined: 9 years ago
Posts: 2
Topic starter  

THANK YOU SO MUCH.


   
ReplyQuote
 Hans
(@hans)
Famed Member Admin
Joined: 11 years ago
Posts: 2791
 

No problem - hope it was you were looking for 


   
ReplyQuote
Share: