I-WS2812B: umlingo we-RGB LED strip

Umtya we-WS2812B RGB

Ngokuqinisekileyo kufuneka wongeze umbala wombala kwiiprojekthi zakho ze-DIY. Ngenxa yoku, abenzi abaninzi basebenzisa ezaziwayo I-WS2812B RGB ye-Strip ye-LED, onokufikelela kuyo kulawulo lombala ohlukileyo kunye nefuthe lokukhanyisa elinomtsalane kwiiprojekthi zakho. Ewe ziziziqwengana ezihambelana ngokupheleleyo neebhodi zeArduino, ke ngekhe ubenangxaki xa uzama ukuzidibanisa.

Ungazifumana kwi- ubude bemitha enyeUmzekelo, nangona zinokwahluka ngokuxhomekeka kuhlobo loxinano lwee-LED kwimitha nganye abanayo. Umzekelo, kukho ii-LEDs ezingama-30 ukuya kwii-144 ze-LED. Nangona kunjalo, ukuba ufuna ubude obude ukufumana indawo enkulu, unokukhetha ezinye kwimarike enjengeepaneli ze-RGB ze-LED okanye ungasoloko usebenzisa imichilo eliqela ...

Le micu ayikho enye into ngaphandle uthotho lwee-RGB ze-RGB ezidibeneyo kwaye inyuswe kwinkxaso efanayo ukuze iziqhekeze zibe yimicu. Kodwa ukusebenza kwayo kuyafana kwii-RGB ze-RGB ezahlukileyo.

Yintoni i-WS2812B?

I-RGB WS2812B ikhanyisile umtya we-LED

Ngokwenyani i-WS2812B asiyoyomtya ngokwawo, kodwa nganye nganye iiseli okanye iipleyiti ze-RGB ze-LED ezincinci ezibandakanya. Banokudibaniswa ngokwendlela yomtya okanye iphaneli, ukuze wenze ubumbeko ohlukeneyo ngokwenani kunye nemilo. Imigca eyenziwayo yimigca eguqukayo, kodwa unokufumana i-WS2812B kwiiphaneli zePCB ezingekhoyo.

Ukuba uyafuna, unokufumana izixhobo WS2812B ngokwahlukeneyo ukwenza iimilo ozifunayo. Umzekelo, malunga neeyunithi ezili-100 zazo zihlala zibiza kancinane ngaphezulu kwe- € 10.

I-rgb ikhokelele ukusika

Kuya kufuneka uyazi ukuba uyabaphosa ungazisika ngesikere naphina apho ufuna khona, oko akuthethi ukuba bayeke ukusebenza. Ke unokuba nee-RGB ze-LED ozifunayo kuphela. Ngapha koko inamanqaku athile (iiphedi ezintathu zobhedu) onokuwasika. Ukuba usika ezi pads, uya kuba neendlela ezintathu kwicala elinye lomtya kwaye kwelinye icala ukuba ufuna ukusebenzisa ezinye iziqwenga, kuzo ungazisonga izikhonkwane zonxibelelwano olulula.

Ukuphuma kunye nedatha

WS2812B kwiseli elula

Isisele esizimeleyo seWS2812B esinegalelo kunye neziphumo

Ngolwazi oluthe kratya malunga ne- Umtya we-RGB we-WS2812B Uyakwazi ukufunda ugcino lwedatha enikezelwa ngumenzi ngamnye, apho unokujonga kuzo zonke iinkcukacha zobungakanani kunye neempawu zobuchwephesha ukuze wazi ukuba uzisebenzisa njani ngokufanelekileyo, ukongeza kokwazi onke amabakala okusebenza kunye nemida.

Ngokuphathelele isikhonkwaneAyisiyongxaki iphambili nokuba, le micu inonxibelelwano olulula onokuluqonda kwasekuqaleni ngaphandle kolwazi oluninzi. Zintathu kuphela ezikhoyo, nangona iseli nganye ye-WS2812B inonxibelelwano oluninzi ...

Kufuneka nje xhuma kumtya ngamnye ipini ye-Vcc eyondla umtya ukuya kwi-5V ukusuka e-Arduino okanye ukusuka kunikezelo lwamandla olwahlukileyo, i-GND emhlabeni, ewe, kwaye ekugqibeleni i-DI yenye eya kuya kuyo nayiphi na imveliso ye-microcontroller ukuze isebenze Ii-RGB ze-LED kumtya.

Ukuba ujonga iseli yeWS2812B Uya kubona ukuba ineDatha yokungena okanye yokufaka kwe-DI, kunye nonikezelo lwamandla lweVcc kunye neGND. Emva koko iya kuba nezinye iziphumo ezintathu, ezo ziya kudityaniswa kwiseli elandelayo yomtya, kwaye iseli elandelayo iya kuba neziphumo zayo eziqhagamshelwe kwigalelo elilandelayo njalo njalo de kugqitywe wonke umtya ...

Yiyo kanye loo nto I-DI okanye igalelo ledatha leyo inomdla wokumisela ii-RGBs ze-RGB, kwaye enye iya kudityaniswa kwiDatha ngaphandle okanye YENZA eya kuthatha olo lwazi luye kwikhonkco elilandelayo kumtya. Kwaye ke isasazeka kulo lonke eli qhekeza.

Thenga ii-WS2812B RGB LED Strips

Uluhlu lwe-RGB ye-LED

Unga thenga ngexabiso elingekho phezulu kakhulu kwiivenkile ezahlukeneyo ezizodwa. Unazo kwiAmazon ngeendlela ezahlukeneyo. Eminye imizekelo yile:

Ukuvavanywa ngeArduino kunye neWS2812B

Arduino UNO kunye ne-WS2812B schema

Njengoko unokucinga, kulula kakhulu ukwenza izikhonkwane ezintathu qhagamshela kwi-arduino njengoko ubona kwisazobe esingentla. Kuya kufuneka uqhagamshele i-5v kunye ne-GND kwi-WS2812B strip, kunye ne-DI kwimveliso oyifunayo kwiArduino. Khumbula ukuba xa utshintsha ipini kufuneka uguqule ikhowudi yemvelaphi ukuze inkqubo isebenze kakuhle.

Ithala lencwadi lisetyenzisiwe INKQUBO ye-LED ekhawulezayo ukwenza izinto zibe lula kwaye ufumane imisebenzi elula yokuqhuba ii-RGB ze-LED. Ukuyikhuphela kwaye uyidibanise ngokufanelekileyo kwi-Arduino IDE, khuphela nje ilayibrari kule khonkco, emva koko unzip iZIP kwaye unike igama kwakhona isikhombisi esingafakwanga okanye ifolda njenge-FastLED, emva koko uhambise loo folda kwindawo apho iilayibrari ze-Arduino IDE zifakelwe kufakelo lwakho . Emva koko phinda uvule i-Arduino IDE kwaye iya kuba ilungile ...

Ngokuphathelele ikhowudi yomzobo, kunokuba lula njengekhowudi elandelayo. Ukuba awufuni ukukopa kunye nokuncamathisela, ungayifumana phakathi kwemizekelo esele ifikile. Ke yiya kwiFayile> Imizekelo> FastLED> ColourPalette.

Khumbula ukutshintsha i-pin 14 ukusuka kumzekelo uye ku-5 oyile ndiyisebenzisileyo kumzobo. Okanye unokuqhagamshela kwipini ye-14 kwaye uphephe ukuguqula ikhowudi. Njengoko ukhetha.
#include <FastLED.h>

#define LED_PIN     5
#define NUM_LEDS    14
#define BRIGHTNESS  64
#define LED_TYPE    WS2811
#define COLOR_ORDER GRB
CRGB leds[NUM_LEDS];

#define UPDATES_PER_SECOND 100

// This example shows several ways to set up and use 'palettes' of colors
// with FastLED.
//
// These compact palettes provide an easy way to re-colorize your
// animation on the fly, quickly, easily, and with low overhead.
//
// USING palettes is MUCH simpler in practice than in theory, so first just
// run this sketch, and watch the pretty lights as you then read through
// the code.  Although this sketch has eight (or more) different color schemes,
// the entire sketch compiles down to about 6.5K on AVR.
//
// FastLED provides a few pre-configured color palettes, and makes it
// extremely easy to make up your own color schemes with palettes.
//
// Some notes on the more abstract 'theory and practice' of
// FastLED compact palettes are at the bottom of this file.



CRGBPalette16 currentPalette;
TBlendType    currentBlending;

extern CRGBPalette16 myRedWhiteBluePalette;
extern const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM;


void setup() {
    delay( 3000 ); // power-up safety delay
    FastLED.addLeds<LED_TYPE, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalLEDStrip );
    FastLED.setBrightness(  BRIGHTNESS );
    
    currentPalette = RainbowColors_p;
    currentBlending = LINEARBLEND;
}


void loop()
{
    ChangePalettePeriodically();
    
    static uint8_t startIndex = 0;
    startIndex = startIndex + 1; /* motion speed */
    
    FillLEDsFromPaletteColors( startIndex);
    
    FastLED.show();
    FastLED.delay(1000 / UPDATES_PER_SECOND);
}

void FillLEDsFromPaletteColors( uint8_t colorIndex)
{
    uint8_t brightness = 255;
    
    for( int i = 0; i < NUM_LEDS; i++) {
        leds[i] = ColorFromPalette( currentPalette, colorIndex, brightness, currentBlending);
        colorIndex += 3;
    }
}


// There are several different palettes of colors demonstrated here.
//
// FastLED provides several 'preset' palettes: RainbowColors_p, RainbowStripeColors_p,
// OceanColors_p, CloudColors_p, LavaColors_p, ForestColors_p, and PartyColors_p.
//
// Additionally, you can manually define your own color palettes, or you can write
// code that creates color palettes on the fly.  All are shown here.

void ChangePalettePeriodically()
{
    uint8_t secondHand = (millis() / 1000) % 60;
    static uint8_t lastSecond = 99;
    
    if( lastSecond != secondHand) {
        lastSecond = secondHand;
        if( secondHand ==  0)  { currentPalette = RainbowColors_p;         currentBlending = LINEARBLEND; }
        if( secondHand == 10)  { currentPalette = RainbowStripeColors_p;   currentBlending = NOBLEND;  }
        if( secondHand == 15)  { currentPalette = RainbowStripeColors_p;   currentBlending = LINEARBLEND; }
        if( secondHand == 20)  { SetupPurpleAndGreenPalette();             currentBlending = LINEARBLEND; }
        if( secondHand == 25)  { SetupTotallyRandomPalette();              currentBlending = LINEARBLEND; }
        if( secondHand == 30)  { SetupBlackAndWhiteStripedPalette();       currentBlending = NOBLEND; }
        if( secondHand == 35)  { SetupBlackAndWhiteStripedPalette();       currentBlending = LINEARBLEND; }
        if( secondHand == 40)  { currentPalette = CloudColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 45)  { currentPalette = PartyColors_p;           currentBlending = LINEARBLEND; }
        if( secondHand == 50)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = NOBLEND;  }
        if( secondHand == 55)  { currentPalette = myRedWhiteBluePalette_p; currentBlending = LINEARBLEND; }
    }
}

// This function fills the palette with totally random colors.
void SetupTotallyRandomPalette()
{
    for( int i = 0; i < 16; i++) {
        currentPalette[i] = CHSV( random8(), 255, random8());
    }
}

// This function sets up a palette of black and white stripes,
// using code.  Since the palette is effectively an array of
// sixteen CRGB colors, the various fill_* functions can be used
// to set them up.
void SetupBlackAndWhiteStripedPalette()
{
    // 'black out' all 16 palette entries...
    fill_solid( currentPalette, 16, CRGB::Black);
    // and set every fourth one to white.
    currentPalette[0] = CRGB::White;
    currentPalette[4] = CRGB::White;
    currentPalette[8] = CRGB::White;
    currentPalette[12] = CRGB::White;
    
}

// This function sets up a palette of purple and green stripes.
void SetupPurpleAndGreenPalette()
{
    CRGB purple = CHSV( HUE_PURPLE, 255, 255);
    CRGB green  = CHSV( HUE_GREEN, 255, 255);
    CRGB black  = CRGB::Black;
    
    currentPalette = CRGBPalette16(
                                   green,  green,  black,  black,
                                   purple, purple, black,  black,
                                   green,  green,  black,  black,
                                   purple, purple, black,  black );
}


// This example shows how to set up a static color palette
// which is stored in PROGMEM (flash), which is almost always more
// plentiful than RAM.  A static PROGMEM palette like this
// takes up 64 bytes of flash.
const TProgmemPalette16 myRedWhiteBluePalette_p PROGMEM =
{
    CRGB::Red,
    CRGB::Gray, // 'white' is too bright compared to red and blue
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Black,
    
    CRGB::Red,
    CRGB::Red,
    CRGB::Gray,
    CRGB::Gray,
    CRGB::Blue,
    CRGB::Blue,
    CRGB::Black,
    CRGB::Black
};



// Additionl notes on FastLED compact palettes:
//
// Normally, in computer graphics, the palette (or "color lookup table")
// has 256 entries, each containing a specific 24-bit RGB color.  You can then
// index into the color palette using a simple 8-bit (one byte) value.
// A 256-entry color palette takes up 768 bytes of RAM, which on Arduino
// is quite possibly "too many" bytes.
//
// FastLED does offer traditional 256-element palettes, for setups that
// can afford the 768-byte cost in RAM.
//
// However, FastLED also offers a compact alternative.  FastLED offers
// palettes that store 16 distinct entries, but can be accessed AS IF
// they actually have 256 entries; this is accomplished by interpolating
// between the 16 explicit entries to create fifteen intermediate palette
// entries between each pair.
//
// So for example, if you set the first two explicit entries of a compact 
// palette to Green (0,255,0) and Blue (0,0,255), and then retrieved 
// the first sixteen entries from the virtual palette (of 256), you'd get
// Green, followed by a smooth gradient from green-to-blue, and then Blue.



Yiba ngowokuqala ukuphawula

Shiya uluvo lwakho

Idilesi yakho ye email aziyi kupapashwa. ezidingekayo ziphawulwe *

*

*

  1. Uxanduva lwedatha: UMiguel Ángel Gatón
  2. Injongo yedatha: Ulawulo lwe-SPAM, ulawulo lwezimvo.
  3. Umthetho: Imvume yakho
  4. Unxibelelwano lwedatha: Idatha ayizukuhanjiswa kubantu besithathu ngaphandle koxanduva lomthetho.
  5. Ukugcinwa kweenkcukacha
  6. Amalungelo: Ngalo naliphi na ixesha unganciphisa, uphinde uphinde ucime ulwazi lwakho.