日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

【小项目关键技术五】控制全彩 WS2812 灯环/灯带

發(fā)布時(shí)間:2025/4/5 编程问答 16 豆豆
生活随笔 收集整理的這篇文章主要介紹了 【小项目关键技术五】控制全彩 WS2812 灯环/灯带 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

Ref: Arduino控制WS2812燈帶(燈環(huán))

#include <FastLED.h>#define LED_PIN 13// Information about the LED strip itself #define NUM_LEDS 24 #define CHIPSET WS2811 #define COLOR_ORDER GRB CRGB leds[NUM_LEDS];#define BRIGHTNESS 128// FastLED v2.1 provides two color-management controls: // (1) color correction settings for each LED strip, and // (2) master control of the overall output 'color temperature' // // THIS EXAMPLE demonstrates the second, "color temperature" control. // It shows a simple rainbow animation first with one temperature profile, // and a few seconds later, with a different temperature profile. // // The first pixel of the strip will show the color temperature. // // HELPFUL HINTS for "seeing" the effect in this demo: // * Don't look directly at the LED pixels. Shine the LEDs aganst // a white wall, table, or piece of paper, and look at the reflected light. // // * If you watch it for a bit, and then walk away, and then come back // to it, you'll probably be able to "see" whether it's currently using // the 'redder' or the 'bluer' temperature profile, even not counting // the lowest 'indicator' pixel. // // // FastLED provides these pre-conigured incandescent color profiles: // Candle, Tungsten40W, Tungsten100W, Halogen, CarbonArc, // HighNoonSun, DirectSunlight, OvercastSky, ClearBlueSky, // FastLED provides these pre-configured gaseous-light color profiles: // WarmFluorescent, StandardFluorescent, CoolWhiteFluorescent, // FullSpectrumFluorescent, GrowLightFluorescent, BlackLightFluorescent, // MercuryVapor, SodiumVapor, MetalHalide, HighPressureSodium, // FastLED also provides an "Uncorrected temperature" profile // UncorrectedTemperature;#define TEMPERATURE_1 Tungsten100W #define TEMPERATURE_2 OvercastSky// How many seconds to show each temperature before switching #define DISPLAYTIME 24 // How many seconds to show black between switches #define BLACKTIME 1void loop() {// draw a generic, no-name rainbowstatic uint8_t starthue = 0;fill_rainbow( leds + 1, NUM_LEDS - 1, --starthue, 20);// Choose which 'color temperature' profile to enable.uint8_t secs = (millis() / 1000) % (DISPLAYTIME * 2);if( secs < DISPLAYTIME) {FastLED.setTemperature( TEMPERATURE_1 ); // first temperatureleds[0] = TEMPERATURE_1; // show indicator pixel} else {FastLED.setTemperature( TEMPERATURE_2 ); // second temperatureleds[0] = TEMPERATURE_2; // show indicator pixel}// Black out the LEDs for a few secnds between color changes// to let the eyes and brains adjustif( (secs % DISPLAYTIME) < BLACKTIME) {memset8( leds, 0, NUM_LEDS * sizeof(CRGB));}FastLED.show();FastLED.delay(8); }void setup() {delay( 3000 ); // power-up safety delay// It's important to set the color correction for your LED strip here,// so that colors can be more accurately rendered through the 'temperature' profilesFastLED.addLeds<CHIPSET, LED_PIN, COLOR_ORDER>(leds, NUM_LEDS).setCorrection( TypicalSMD5050 );FastLED.setBrightness( BRIGHTNESS ); }

上述代碼效果如下:

總結(jié)

以上是生活随笔為你收集整理的【小项目关键技术五】控制全彩 WS2812 灯环/灯带的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。