POE PICO供电的灯塔(W5100S_POE_EVB_PICO)
转发: Light Tower Powered by W5100S_POE_EVB_PICO(POE+PICO)
项目介绍
Light Tower是一个POE项目,使用回形针、气泡纸、WS2812和W5100_POE_EVB_PICO。
测试图片。
事实上,Light Tower项目的目的是为了测试W5100S_POE_EVB_PICO的POE电源负载能力。
W5100S_POE_EVB_PICO 的 POE 功能由 POE 模块“POE-P1”(暂定名)提供。 因为我没有数字负载设备,所以想简单的直接连接WS2812来测试。 因为WS2812的负载基本确定,根据WS2812的手册:
“LED灯带应使用5V电源供电。在5V电压下,每个LED消耗约50mA的电流”,我使用了3条带有12个WS2812灯珠的灯带。
所以“灯塔”的总功率应为3*12*5V*0.05mA=9W。
实际功率应该比这个小,这只是一个简单的测试,好玩才是第一位;
我用铁丝将三个灯环固定(将回形针拉直),形成三层结构。
然后将它们连接到W5100S_POE_EVB_PICO。 该产品的介绍请参考以下链接:
W5100S-POE-EVB-PICO(POE development board for RP2040)
只需一个IO即可控制整个WS2812阵列。
我使用回形针作为电容式按钮的触摸板。 它也由 IO 控制。
整个项目的总结就是通过按钮控制WS2812的灯光模式,通过Blynk的移动应用程序控制WS2812的灯光颜色。
我们先来处理触摸按钮部分。 我们初始化一个触摸按钮,
const int touch_threshold_adjust = 300;
const int touch_pins[] = {27};
const int touch_count = sizeof(touch_pins) / sizeof(int);
TouchyTouch touches[touch_count];
uint32_t time_now = 0;
然后将我们的处理流程放在其按下和释放动作中,如下:
void Touch_handling()
{
// key handling
for ( int i = 0; i < touch_count; i++) {
touches[i].update();
if ( touches[i].rose() ) {
Serial.print("Button:");
Serial.println(i);
ws2812fx.setMode((ws2812fx.getMode() + 1) % ws2812fx.getModeCount());
time_now = millis();
}
if ( touches[i].fell() ) {
Serial.printf("Release:");
Serial.println(i);
if((millis()-time_now)>500)
{
if(light_mode)
{
light_mode = 0;
}else{
light_mode = 1;
}
Serial.print("Time_enough");
}
}
}
}
我们先来处理触摸按钮部分。 我们初始化一个触摸按钮,然后将我们的处理流程放在其按下和释放动作中,如下所示:
当按钮按下时,即touches[i].rose(),我们设置WS2812的灯光模式,并记录当前时间; 当按钮松开时,即touches[i].fell(),判断是Click还是长按,如果是长按,则切换到灯控模式。
Blynk云通过RGB转盘插件控制语句输出,
语法如下:
int r;
int g;
int b;
BLYNK_WRITE(V5) {
// Called when virtual pin V2 is updated from the Blynk.App
// V2 is a datastream of data type String assigned to a
// Blynk.App ZeRGBa widget.
r = param[0].asInt();
g = param[1].asInt();
b = param[2].asInt();
Serial.print("V2: r = ");
Serial.print(r);
Serial.print("\t g=");
Serial.print(g);
Serial.print("\t b=");
Serial.println(b);
ws2812fx.setColor(((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b));
light_mode = 1;
} // BLYNK_WRITE(V5)
因此我们可以从 BLYNK 中获取 R G B 信息,并通过 Loop() 循环将该颜色插入到 WS2812 灯光模式中。
if(light_mode)
{
ws2812fx.setColor(((uint32_t)r << 16 | (uint32_t)g << 8 | (uint32_t)b));
}
通过 (uint32_t)r << 16 | 转换为 RGB888 (uint32_t)g << 8 | (uint32_t)b。
完毕。
文件