驴友花雕
发表于 2022-7-14 20:27:55
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序四:循环调用不同类型的显示效果
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序四:循环调用不同类型的显示效果
*/
#include <FastLED.h>
#define DATA_PIN 6
#define NUM_LEDS 24
#define BRIGHTNESS33
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds;
#define UPDATES_PER_SECOND 100
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
ws2812_fill_all();
moving_three_led();
rgb_chasing();
}
void ws2812_fill_all() {
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Red;
delay(10);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Black;
delay(10);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Green;
delay(10);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Black;
delay(10);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Blue;
delay(10);
FastLED.show();
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Black;
delay(10);
FastLED.show();
}
}
void moving_three_led() {
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Red;
leds = CRGB::Green;
leds = CRGB::Blue;
FastLED.show();
delay(100);
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB::Black;
//delay(5);
}
}
}
void rgb_chasing() {
int ms = 50;
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB(100, 0, 0);
FastLED.show();
delay(ms);
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB(0, 100, 0);
FastLED.show();
delay(ms);
}
for (int i = 0; i < NUM_LEDS; i++) {
leds = CRGB(0, 0, 100);
FastLED.show();
delay(ms);
}
}
驴友花雕
发表于 2022-7-14 20:29:00
实验场景图动态图
驴友花雕
发表于 2022-7-15 17:14:51
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序五:具有移动效果的渐变调色板
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序五:具有移动效果的渐变调色板
*/
#include <FastLED.h>
#define DATA_PIN 6
#define NUM_LEDS 24
#define BRIGHTNESS100
#define LED_TYPE WS2812B
#define COLOR_ORDER GRB
CRGB leds;
uint8_t paletteIndex = 0;
DEFINE_GRADIENT_PALETTE( temperature_gp ) {
0, 1, 27,105,
14, 1, 27,105,
14, 1, 40,127,
28, 1, 40,127,
28, 1, 70,168,
42, 1, 70,168,
42, 1, 92,197,
56, 1, 92,197,
56, 1,119,221,
70, 1,119,221,
70, 3,130,151,
84, 3,130,151,
84,23,156,149,
99,23,156,149,
99,67,182,112,
113,67,182,112,
113, 121,201, 52,
127, 121,201, 52,
127, 142,203, 11,
141, 142,203, 11,
141, 224,223,1,
155, 224,223,1,
155, 252,187,2,
170, 252,187,2,
170, 247,147,1,
184, 247,147,1,
184, 237, 87,1,
198, 237, 87,1,
198, 229, 43,1,
212, 229, 43,1,
212, 220, 15,1,
226, 220, 15,1,
226, 171,2,2,
240, 171,2,2,
240,80,3,3,
255,80,3,3};
CRGBPalette16 myPalette = temperature_gp;
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
FastLED.setBrightness(BRIGHTNESS);
}
void loop() {
fill_palette(leds, NUM_LEDS, paletteIndex, 255 / NUM_LEDS, myPalette, BRIGHTNESS, LINEARBLEND);
EVERY_N_MILLISECONDS(10) {
paletteIndex++;
}
FastLED.show();
}
驴友花雕
发表于 2022-7-15 17:16:52
实验场景图动态图
驴友花雕
发表于 2022-7-15 17:38:25
本帖最后由 驴友花雕 于 2022-7-15 19:13 编辑
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序六:逐点变换流水灯
实验开源仿真编程(Linkboy V4.63)
驴友花雕
发表于 2022-7-15 17:40:35
实验场景图仿真动态图
驴友花雕
发表于 2022-7-15 19:13:22
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序七:七彩流水灯
实验开源仿真编程(Linkboy V4.63)
驴友花雕
发表于 2022-7-15 19:18:15
本帖最后由 驴友花雕 于 2022-7-15 19:21 编辑
实验场景图仿真动态图
驴友花雕
发表于 2022-7-15 19:20:07
实验场景图动态图
驴友花雕
发表于 2022-7-15 19:38:51
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序八:流光彩虹灯带
实验开源仿真编程(Linkboy V4.63)
驴友花雕
发表于 2022-7-15 19:41:20
实验场景图动态图
驴友花雕
发表于 2022-7-16 19:08:16
今天实验中,不小心烧掉一颗5050灯珠
驴友花雕
发表于 2022-7-16 19:13:10
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序九:循环三色流水彩灯
/*
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序九:循环三色流水彩灯
*/
#include <FastLED.h>
#define NUM_LEDS 24
#define DATA_PIN 6
#define COLOR_ORDER GRB
#define LED_TYPE WS2812B
#define POT A0
CRGB leds;
int onePos = 2;
int twoPos = 2;
int shePos = 2;
byte oneDir = 0;
byte twoDir = 0;
byte sheDir = 0;
void setup() {
FastLED.addLeds<LED_TYPE, DATA_PIN, COLOR_ORDER>(leds, NUM_LEDS);
}
void loop() {
if (analogRead(POT) > NUM_LEDS) {
onePos = map(analogRead(POT), 0, 524, 0, NUM_LEDS);
}
leds = CRGB(255, 0, 0);
leds = CRGB(255, 0, 0);
leds = CRGB(255, 0, 0);
leds = CRGB(0, 255, 0);
leds = CRGB(0, 255, 0);
leds = CRGB(0, 255, 0);
leds = CRGB(0, 0, 255);
leds = CRGB(0, 0, 255);
leds = CRGB(0, 0, 255);
FastLED.show();
delay(150);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
leds = CRGB(0, 0, 0);
FastLED.show();
if (oneDir == 0) {
onePos += 3;
if (onePos >= NUM_LEDS) {
onePos = NUM_LEDS;
oneDir = 1;
}
}
else {
if (oneDir == 1) {
onePos -= 2;
if (onePos <= 0) {
onePos = 0;
oneDir = 0;
}
}
}
if (sheDir == 0) {
shePos += 3;
if (shePos >= NUM_LEDS) {
shePos = NUM_LEDS;
sheDir = 1;
}
}
else {
if (sheDir == 1) {
shePos -= 2;
if (shePos <= 0) {
shePos = 0;
sheDir = 0;
}
}
}
if (twoDir == 0) {
twoPos += 2;
if (twoPos >= NUM_LEDS) {
twoPos = NUM_LEDS;
twoDir = 1;
}
}
else {
if (twoDir == 1) {
twoPos -= 2;
if (twoPos <= 0) {
twoPos = 0;
twoDir = 0;
}
}
}
}
驴友花雕
发表于 2022-7-16 19:18:59
实验场景图动态图
驴友花雕
发表于 2022-7-16 20:30:27
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序十:四色流光彩虹灯带
实验开源图形编程(Mind+、编玩边学)
驴友花雕
发表于 2022-7-16 20:36:27
实验场景图动态图
驴友花雕
发表于 2022-7-16 20:41:45
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序十一:移动四色流水彩虹灯
实验开源图形编程(Mind+、编玩边学)
驴友花雕
发表于 2022-7-16 20:46:17
实验场景图动态图
驴友花雕
发表于 2022-7-17 10:07:23
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序十二:随机色彩的流动彩虹灯
实验开源图形编程(Mind+、编玩边学)
驴友花雕
发表于 2022-7-17 10:10:51
实验场景图动态图
驴友花雕
发表于 2022-7-17 10:41:01
【Arduino】168种传感器模块系列实验(资料代码+仿真编程+图形编程)
实验二百一十六:WS2812B幻彩LED灯带 5V全彩灯条5050灯珠内置IC炫彩单点单控软灯条模块
实验程序十三:随机柱状跳跃灯
实验开源图形编程(Mind+、编玩边学)