Tabbas kuna buƙatar ƙara taɓa launi zuwa ayyukanku na DIY. Saboda wannan, masu yin yawa suna amfani da sanannen WS2812B RGB LED Tsiri, tare da abin da za'a iya samun ikon sarrafa launuka daban-daban da kuma tasirin hasken wuta mai kayatarwa don ayyukanku. Tabbas sun kasance tsintsiya madaidaiciya tare da allon Arduino, don haka ba zaku sami matsala yayin ƙoƙarin haɗa su ba.
Kuna iya samun su a ciki tsawo na mita 1, misali, kodayake suna iya banbanta dangane da nau'ikan nauyin LEDs a kowane mita da suke dashi. Misali, akwai daga 30 LED zuwa 144 LEDs. Koyaya, idan kuna buƙatar tsayi mai tsayi don samun ƙasa mai girma, ku ma kuna da wasu zaɓuɓɓuka a kasuwa kamar su RGB LED bangarori ko koyaushe kuna iya amfani da dama da dama ...
Wadannan tube ba komai bane jerin RD LEDs masu haɗuwa kuma an hau su akan tallafi na gama gari don tara su cikin tsiri. Amma aikinsa yayi kama da RGB LEDs daban.
Menene WS2812B?
A gaskiya WS2812B ba shine tsiri kanta ba, amma kowane ɗayan Kwayoyin ko ƙaramin RG LED faranti waɗanda suka haɗa da. Za a iya haɗa su ta hanyar tsiri ko faifai, don haka zaku iya yin gyare-gyare iri-iri dangane da lambar su da fasalin su. Theididdigar da aka gyara sune madaidaiciya, amma zaka iya samun WS2812B akan bangarorin PCB waɗanda ba haka bane.
Idan kanaso, zaka iya samun na'urorin WS2812B daban don ƙirƙirar siffofin da kuke buƙatar kanku. Misali, kimanin raka'a 100 daga cikinsu galibi suna kashe kuɗi sama da € 10.
Ya kamata kuma ku sani cewa kuna jefa su zaka iya yanke su tare da almakashi duk inda kuke buƙata, wannan baya nuna cewa sun daina aiki. Don haka kuna iya samun RGB LEDs kawai da kuke buƙata. A zahiri, yana da wasu alamomi (kushin jan ƙarfe uku) waɗanda zaku iya yankewa ta ciki. Idan ka yanke ta waɗannan faya-fayan za ka sami waƙoƙi uku a gefe ɗaya na tsiri kuma ɗayan kuma idan kana son sake amfani da waɗanyan ɓangarorin, za ka iya siyar da fil ɗin a gare su don sauƙin haɗi.
Pinout da takaddun bayanai
Don ƙarin bayani game da RGB LED tsiri WS2812B Kuna iya karantawa da takaddun bayanan wanda kowane mai sana'anta ke bayarwa, a can zaku iya tuntuɓar duk cikakkun bayanai game da girma da halaye na fasaha don sanin yadda ake amfani da su yadda yakamata, ban da sanin duk matakan aiki da iyaka.
Amma ga kurajeBa babbar matsala bane, waɗannan yankan suna da haɗi mai sauƙi wanda zaku iya mallake shi tun daga farko ba tare da ilimin da yawa ba. Akwai guda uku kawai, kodayake kowane kwayar WS2812B a zahiri tana da ƙarin haɗi ...
Kawai dole ne haɗa akan kowane tsiri Vcc pin wanda yake ciyar da tsiri zuwa 5V daga Arduino ko daga wani wutan lantarki daban, GND zuwa kasa, ba shakka, kuma a karshe DI wanda shine dayan wanda zai tafi duk wani abun da microcontroller ya fitar don kunna RGB LEDs akan tsiri.
Idan ka duba kwayar WS2812B Za ku ga cewa yana da shigarwar Data In ko DI, da kuma wutar lantarki ta Vcc da GND. Sannan zata sami wasu kayan masarufi guda uku, wadannan za'a hada su da sel na gaba na tsiri, kuma kwaya ta gaba za'a hada kayan aikinta da shigar na gaba da sauransu har sai an gama dukkan tsirin ...
Daidai ne cewa DI ko shigar da bayanai wanda yake da ban sha'awa don saita LEDs na RGB, kuma wannan za a haɗa shi zuwa Data Out ko DO wanda zai ɗauki wannan bayanin zuwa mahaɗin na gaba a cikin tsiri. Sabili da haka ya bazu a ko'ina cikin tsiri.
Sayi WS2812B RGB LED Strips
Za ka iya saya a farashin da ba shi da tsada a manyan shaguna na musamman. Hakanan kuna da su a cikin Amazon a cikin tsari daban-daban. Wasu misalai sune:
- RGB LED Strips WS2812B na 60 LEDs / m.
- RGB LED Strips WS2812B na 100 LEDs / m.
- RGB LED Strips WS2812B na 144 LEDs / m.
- WS2812B RGB LED Tsiri na mita 5 na LED 30.
- WS2812B RGB LED Tsiri na mita 5 na LED 60.
- WS2812B panel
- 5 mita na RGB LEDs.
Gwaji tare da Arduino da WS2812B
Kamar yadda zaku iya tunanin, tare da fil uku kawai yana da sauƙin haɗi zuwa arduino kamar yadda kake gani a zane a sama. Dole ne kawai ku haɗa 5v da GND zuwa tsirin WS2812B, da DI zuwa fitowar da kuke so akan Arduino. Ka tuna cewa idan ka canza fil dole ne kuma ka canza lambar tushe don shirin yayi aiki daidai.
Amma ga lambar zane, yana iya zama mai sauƙin kamar lambar mai zuwa. Idan ba kwa son kwafa da liƙawa, kuna iya samun sa tsakanin misalan da suka zo riga. Don haka je Fayil> Misalai> FastLED> Launi mai launi.
#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.