之前我发了一个显示器流光溢彩的视频,颜色效果还是很不错的。本文就给大家说说制作方法,过程非常简单,相信每个人都可以轻松搞定。
显示器流光溢彩
1、准备材料
ws2812b灯带(带背胶);
arduino (nano、uno都ok);
usb线;
导线(杜邦线);
AmbiBox软件;
arduino软件;
2、贴灯带和接线
将灯带贴到显示器背面,具体贴法根据自己显示器的情况灵活安排,我的是这样贴的。
然后将灯带的三根线接到arduino上,分别是5v,GND和信号线,信号线接D2就行。
3、下载arduino代码
打开arduino开发环境,首先安装FastLED库,代码用了这个库来驱动ws2812b。
新建工程,将下面的代码复制到arduino IDE中,修改一下NUM_LEDS宏的值为你的灯的个数,修改DATA_PIN为灯带数据线接的arduino端口号。
/** <a class="decoration-color" href="https://buy.icxbk.com/index.php?ctl=Product&met=lists&key_type=1&keywords=arduino" target="_blank">Arduino</a> interface for the use of WS2812 strip LEDs* Uses Adalight protocol and is compatible with Boblight, Prismatik etc...* "Magic Word" for synchronisation is 'Ada' followed by LED High, Low and Checksum* @author: Wifsimster <[email protected]>* @library: FastLED v3.001* @date: 11/22/2015*/#include "FastLED.h"#define NUM_LEDS 39 //(灯带一共有多少个LED?)#define DATA_PIN 2 //(绿色的数据线接在arduino几号端口?)// Baudrate, higher rate allows faster refresh rate and more LEDs (defined in /etc/boblight.conf)#define serialRate 115200// Adalight sends a "Magic Word" (defined in /etc/boblight.conf) before sending the pixel datauint8_t prefix[] = {'A', 'd', 'a'}, hi, lo, chk, i;// Initialise LED-arrayCRGB leds[NUM_LEDS];void setup() {// Use NEOPIXEL to keep true colorsFastLED.addLeds<neopixel, data_pin="">(leds, NUM_LEDS);// Initial RGB flashLEDS.showColor(CRGB(255, 0, 0));delay(500);LEDS.showColor(CRGB(0, 255, 0));delay(500);LEDS.showColor(CRGB(0, 0, 255));delay(500);LEDS.showColor(CRGB(0, 0, 0));Serial.begin(serialRate);// Send "Magic Word" string to hostSerial.print("Ada\n");}void loop() {// Wait for first byte of Magic Wordfor(i = 0; i < sizeof prefix; ++i) {waitLoop: while (!Serial.available()) ;;// Check next byte in Magic Wordif(prefix[i] == Serial.read()) continue;// otherwise, start overi = 0;goto waitLoop;}// Hi, Lo, Checksumwhile (!Serial.available()) ;;hi=Serial.read();while (!Serial.available()) ;;lo=Serial.read();while (!Serial.available()) ;;chk=Serial.read();// If checksum does not match go back to waitif (chk != (hi ^ lo ^ 0x55)) {i=0;goto waitLoop;}memset(leds, 0, NUM_LEDS * sizeof(struct CRGB));// Read the transmission data and set LED valuesfor (uint8_t i = 0; i < NUM_LEDS; i++) {byte r, g, b;while(!Serial.available());r = Serial.read();while(!Serial.available());g = Serial.read();while(!Serial.available());b = Serial.read();leds[i].r = r;leds[i].g = g;leds[i].b = b;}// Shows new valuesFastLED.show();
修改完毕后就可以编译下载了。这个用过arduino应该都会,我就不罗嗦了。下载完要保持usb线的连接,后边上位机软件会通过它给arduino发送命令和数据。
4、AmbiBox下载安装配置
AmbiBox是我们将会用到的上位机软件,大家可以到它们官网下载,我也会把安装包共享。
安装都是常规步骤,我就不多说了。安装完后打开软件,选择Intelligent backlight display,我们从上到下一一设置。
首先要勾选Use backlight,否则灯带不会跟着屏幕变化。
Mode下拉菜单提供了5种显示方式: 屏幕捕获、静态背景、动态背景、跟随音乐、插件。流光溢彩的效果是屏幕捕获的方式,我们这里选择第一个。
全文阅读:https://www.icxbk.com/article/detail/1652.html