WS2812B: បន្ទះ LED RGB វេទមន្ត

បន្ទះ LED WS2812B RGB

ច្បាស់ណាស់អ្នកត្រូវបន្ថែមការប៉ះនៃពណ៌ទៅនឹងគម្រោង DIY របស់អ្នក។ ចំពោះបញ្ហានេះអ្នកផលិតជាច្រើនប្រើភាពល្បីល្បាញ បន្ទះ LED WS2812B RGBដែលអាចសម្រេចបាននូវការគ្រប់គ្រងពណ៌ដែលមានលក្ខណៈខុសៗគ្នានិងផលប៉ះពាល់ពន្លឺគួរឱ្យទាក់ទាញសម្រាប់គម្រោងរបស់អ្នក។ ជាការពិតណាស់ពួកគេជាបន្ទះដែលឆបគ្នាយ៉ាងពេញលេញជាមួយក្រុមប្រឹក្សា Arduino ដូច្នេះអ្នកនឹងមិនមានបញ្ហាអ្វីទេនៅពេលព្យាយាមបញ្ចូលវា។

អ្នកអាចរកឃើញពួកគេនៅក្នុង ប្រវែង ១ ម៉ែត្រឧទាហរណ៍ទោះបីជាពួកគេអាចប្រែប្រួលអាស្រ័យលើប្រភេទដង់ស៊ីតេនៃ LEDs សម្រាប់ម៉ែត្រនីមួយៗដែលពួកគេមាន។ ឧទាហរណ៍មានពីអំពូល LED ចំនួន ៣០ ដល់ ១៤៤ LED ។ ទោះយ៉ាងណាក៏ដោយប្រសិនបើអ្នកត្រូវការប្រវែងវែងជាងមុនដើម្បីទទួលបានផ្ទៃធំអ្នកក៏មានជម្រើសផ្សេងទៀតនៅលើទីផ្សារដូចជាបន្ទះ LED RGB ឬអ្នកតែងតែអាចប្រើបន្ទះជាច្រើន ...

បន្ទះទាំងនេះមិនមានអ្វីច្រើនជាងនេះទេ ស៊េរីនៃ LED RGB ដែលបានជួបប្រជុំគ្នា និងបានទទួលការគាំទ្រជាទូទៅដើម្បីដាក់ជាក្រុម។ ប៉ុន្តែប្រតិបត្តិការរបស់វាគឺដូចគ្នាបេះបិទទៅនឹងអំពូល LED RGB ដាច់ដោយឡែក។

តើ WS2812B គឺជាអ្វី?

បន្ទះ LED RGB WS2812B បំភ្លឺ

តាមពិត WS2812B មិនមែនជាបន្ទះខ្លួនវាទេប៉ុន្តែវានីមួយៗ កោសិកា ឬចាន LED RGB តូចដែលរួមបញ្ចូល។ ពួកវាអាចត្រូវបានដាក់ជាក្រុមតាមទម្រង់បន្ទះឬបន្ទះដូច្នេះអ្នកអាចធ្វើការកំណត់រចនាសម្ព័ន្ធផ្សេងៗទាក់ទងនឹងចំនួននិងរូបរាងរបស់វា។ បន្ទះដែលបង្កើតជាបន្ទះដែលអាចបត់បែនបានប៉ុន្តែអ្នកក៏អាចរកឃើញ WS2812B នៅលើបន្ទះ PCB ដែលមិនមែន។

ប្រសិនបើអ្នកចង់បានអ្នកអាចរកឃើញឧបករណ៍ WS2812B ដាច់ដោយឡែក ដើម្បីបង្កើតរាងដែលអ្នកត្រូវការដោយខ្លួនឯង។ ឧទាហរណ៍ប្រហែល 100 គ្រឿងនៃពួកគេជាធម្មតាមានតម្លៃបន្តិចជាង 10 ផោន។

rgb ដឹកនាំបន្ទះកាត់

អ្នកក៏គួរតែដឹងថាអ្នកបោះវាចោល អ្នកអាចកាត់វាបាន ជាមួយកន្ត្រៃគ្រប់ទីកន្លែងដែលអ្នកត្រូវការវាមិនមានន័យថាពួកគេឈប់ធ្វើការទេ។ ដូច្នេះអ្នកអាចមានអំពូល LED RGB ដែលអ្នកត្រូវការប៉ុណ្ណោះ។ តាមពិតវាមានសញ្ញាសម្គាល់មួយចំនួន (បន្ទះស្ពាន់បី) ដែលអ្នកអាចកាត់តាម។ ប្រសិនបើអ្នកកាត់បន្ទះទាំងនេះអ្នកនឹងមានផ្លូវដែកចំនួនបីនៅផ្នែកម្ខាងនៃបន្ទះនិងផ្នែកម្ខាងទៀតក្នុងករណីដែលអ្នកចង់ប្រើបំណែកផ្សេងទៀតនៅក្នុងនោះអ្នកអាចលក់ម្ជុលសម្រាប់ការតភ្ជាប់ងាយស្រួល។

Pinout និងសំណុំទិន្នន័យ

WS2812B នៅក្នុងកោសិកាធម្មតា

វាគឺជាកោសិកា WS2812B ឯករាជ្យដែលមានធាតុចូលនិងលទ្ធផលរបស់វា

សម្រាប់ព័ត៌មានបន្ថែមអំពីរបស់អ្នក បន្ទះ LED RGB WS2812B អ្នកអាចអាន សំណុំទិន្នន័យ ផ្តល់ជូនដោយក្រុមហ៊ុនផលិតនីមួយៗនៅទីនោះអ្នកអាចពិគ្រោះព័ត៌មានលម្អិតទាំងអស់នៃវិមាត្រនិងលក្ខណៈបច្ចេកទេសដើម្បីដឹងពីរបៀបប្រើវាឱ្យបានត្រឹមត្រូវបន្ថែមលើការដឹងពីជួរប្រតិបត្តិការនិងដែនកំណត់ទាំងអស់។

ដូចជាសម្រាប់ ខ្ទាស់ចេញវាក៏មិនមែនជាបញ្ហាធំដែរ។ បន្ទះទាំងនេះមានទំនាក់ទំនងសាមញ្ញដែលអ្នកអាចធ្វើជាម្ចាស់ពីដំបូងដោយមិនមានចំណេះដឹងច្រើនពេក។ មានតែបីប៉ុណ្ណោះដែលអាចប្រើបានទោះបីកោសិកា WS2812B នីមួយៗមានទំនាក់ទំនងច្រើនក៏ដោយ…

អ្នកត្រូវតែធ្វើ ភ្ជាប់។ នៅលើឆ្នូតនិមួយៗកូដ PIN Vcc ដែលចិញ្ចឹមឆ្នូតទៅ 5V ពី Arduino ឬពីការផ្គត់ផ្គង់ថាមពលផ្សេងៗ GND ទៅដីហើយទីបំផុត DI ដែលជារបស់មួយផ្សេងទៀតដែលនឹងចូលទៅក្នុងលទ្ធផលណាមួយរបស់ microcontroller ដើម្បីធ្វើឱ្យសកម្ម អំពូល LED RGB នៅលើបន្ទះ។

ប្រសិនបើអ្នកក្រឡេកមើល ក្រឡា WS2812B មួយ អ្នកនឹងឃើញថាវាមានការបញ្ចូលទិន្នន័យអ៊ីនធឺណេតរឺឌីឌីនិងការផ្គត់ផ្គង់ថាមពលវីស៊ីនិងហ្គ្រីន។ បន្ទាប់មកវានឹងមានលទ្ធផលចំនួនបីផ្សេងទៀតលទ្ធផលទាំងនោះនឹងត្រូវភ្ជាប់ទៅនឹងកោសិកាបន្ទាប់នៃបន្ទះហើយកោសិកាបន្ទាប់នឹងមានលទ្ធផលរបស់វាភ្ជាប់ទៅនឹងធាតុបញ្ចូលបន្ទាប់និងបន្តរហូតដល់បន្ទះទាំងមូលត្រូវបានបញ្ចប់ ...

វាច្បាស់ណាស់ DI ឬការបញ្ចូលទិន្នន័យ មួយដែលគួរឱ្យចាប់អារម្មណ៍ក្នុងការកំណត់រចនាសម្ព័ន្ធអេចអិលអេសអេសអេសអេសអេសអេសអេសអេសអេសអេសអេសអេសអេសដែលនឹងភ្ជាប់ព័ត៌មានដូចគ្នាទៅនឹងតំណបន្ទាប់នៅក្នុងបន្ទះ។ ហើយដូច្នេះវារាលដាលពាសពេញបន្ទះ។

ទិញបន្ទះ LED WS2812B RGB

រមៀលឆ្នូត LED RGB

អ្នក​អាច ទិញក្នុងតម្លៃមិនខ្ពស់ នៅក្នុងហាងឯកទេសផ្សេងៗគ្នា។ អ្នកក៏មានពួកគេនៅក្នុងក្រុមហ៊ុន Amazon នៅក្នុងទ្រង់ទ្រាយផ្សេងគ្នា។ ឧទាហរណ៍ខ្លះគឺ៖

ការធ្វើតេស្តជាមួយ Arduino និង WS2812B

Arduino UNO ជាមួយគ្រោងការណ៍ WS2812B

ដូចដែលអ្នកអាចស្រមៃដោយមានតែម្ជុលបីវាងាយស្រួលណាស់ តភ្ជាប់ទៅ Arduino ដូចដែលអ្នកអាចឃើញនៅក្នុងដ្យាក្រាមខាងលើ។ អ្នកគ្រាន់តែភ្ជាប់ខ្សែ 5 វ៉និងហ្រ្វិកទៅនឹងបន្ទះអេសអេស .2812B ហើយឌីអេសទៅនឹងទិន្នផលដែលអ្នកចង់បាននៅលើអារីដូណូ សូមចងចាំថាប្រសិនបើអ្នកប្តូរកូដ PIN របស់អ្នកអ្នកក៏ត្រូវតែកែប្រែកូដប្រភពដើមដើម្បីឱ្យកម្មវិធីដំណើរការបានត្រឹមត្រូវ។

បណ្ណាល័យត្រូវបានប្រើប្រាស់ ម៉ាស្ទ័រអេឡិចត្រូនិចលឿន ដើម្បីធ្វើឱ្យអ្វីៗកាន់តែងាយស្រួលនិងទទួលបានមុខងារសាមញ្ញដើម្បីជំរុញ LED RGB ។ ដើម្បីទាញយកវាហើយបញ្ចូលវាឱ្យបានត្រឹមត្រូវទៅក្នុង Arduino IDE អ្នកគ្រាន់តែទាញយកបណ្ណាល័យពីតំណនោះបន្ទាប់មកពន្លាហ្ស៊ីពហើយប្តូរឈ្មោះថតឯកសារឬថតដែលមិនបានពន្លាទៅជាហ្វាយអេចអេសអេសហើយបន្ទាប់មកប្តូរទីតាំងថតនោះទៅកន្លែងបណ្ណាល័យ Arduino IDE ដែលបានតំឡើងក្នុងការតំឡើងរបស់អ្នក។ ។ បន្ទាប់មកបើក Arduino IDE ឡើងវិញហើយវានឹងរួចរាល់ ...

ដូចជាសម្រាប់ កូដបង្ហាញប្រភេទរូបភាពវាអាចមានលក្ខណៈសាមញ្ញដូចកូដខាងក្រោម។ ប្រសិនបើអ្នកមិនចង់ចម្លងនិងបិទភ្ជាប់អ្នកអាចរកឃើញវាក្នុងចំណោមឧទាហរណ៍ដែលមានរួចហើយ។ ដូច្នេះសូមចូលទៅកាន់ File> ឧទាហរណ៍> FastLED> ColorPalette ។

សូមចាំថាត្រូវប្តូរលេខកូដ ១៤ ពីឧទាហរណ៍ទៅលេខ ៥ ដែលជាលេខមួយដែលខ្ញុំប្រើក្នុងដ្យាក្រាម។ ឬអ្នកអាចភ្ជាប់ទៅម្ជុលលេខ 14 ហើយជៀសវាងការកែប្រែលេខកូដ។ ដូចដែលអ្នកចូលចិត្ត។
#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.



ខ្លឹមសារនៃអត្ថបទប្រកាន់ខ្ជាប់នូវគោលការណ៍របស់យើង ក្រមសីលធម៌វិចារណកថា។ ដើម្បីរាយការណ៍ការចុចកំហុស នៅទីនេះ.

ធ្វើជាយោបល់ដំបូង

ទុកឱ្យយោបល់របស់អ្នក

អាសយដ្ឋានអ៊ីមែលរបស់អ្នកនឹងមិនត្រូវបានបោះពុម្ភ។ អ្នកគួរតែអនុវត្តតាម *

*

*

  1. ទទួលខុសត្រូវចំពោះទិន្នន័យ: មីហ្គែល - ហ្គែលហ្គេតថន
  2. គោលបំណងនៃទិន្នន័យ៖ គ្រប់គ្រង SPAM ការគ្រប់គ្រងមតិយោបល់។
  3. ភាពស្របច្បាប់៖ ការយល់ព្រមរបស់អ្នក
  4. ការប្រាស្រ័យទាក់ទងទិន្នន័យ៖ ទិន្នន័យនឹងមិនត្រូវបានទាក់ទងទៅភាគីទីបីឡើយលើកលែងតែកាតព្វកិច្ចផ្នែកច្បាប់។
  5. ការផ្ទុកទិន្នន័យ៖ មូលដ្ឋានទិន្នន័យដែលរៀបចំដោយបណ្តាញ Occentus (EU)
  6. សិទ្ធិ៖ នៅពេលណាដែលអ្នកអាចដាក់កម្រិតទាញយកមកវិញនិងលុបព័ត៌មានរបស់អ្នក។