WiFi连接LED棒与共享动画

简介:WiFi连接LED条带共用动画

简介:一个从小就有各种典型症状的制造商,一个机器人制造者,一个互联网软件CTO/技术产品经理。

这个项目探索的能力,有一个动画,手从一个酒吧到下一个LED酒吧。他们是WiFi连接的,所以酒吧可以在世界上任何地方,动画将在他们之间移动,创造一个远距离的共享体验。他们也可以在一个位置使用,以避免运行之间的LED信号线的需要-每个酒吧只需要一个墙壁适配器工作。

These bars use Particle Core and Photon processors and WS2812b LEDs. The concern was that handing off an animation from one bar to the next would take too long, but the Particle.io Publish and Subscribe system worked fast enough for basic animations.

第一步:零件

在项目中,每个钢带使用了以下零件:

  • 一种非防水WS2812b LED灯带。我使用了30 /米。非防水性器通常有双面胶带已经连接到它们,以便易于安装。由于通道长,因此每频道需要1米。上面的链接为一米,但如果您正在进行几个时,您也可以获得5米的条带并切割它们。每米的更多LED很好 - 只是确保获得相应的大电源。这些条带中的每个(5050)LED可以在完全时使用高达60mA。

Step 2: Attaching the Box to the Strip

要容纳CPU,我在条带末端使用了一个小项目箱。我确实尝试了一个中心安装选项(稍后更多信息),但最终的一个看起来最好。要将项目盒连接到条带,请使用6“件1/2”宽的1/16“厚铝棒,在盒子和条带之间运行。杆安装在底部以便于拆卸和更换盖子。

盒子需要两个孔才能钻出它。首先是面板安装电源插孔。应该以盒子的外侧为中心,也许较近盖子而不击中它,为CPU提供更多空间。我用一步钻头来获得孔以匹配千斤顶的大小。一种步进钻真的是最好和最安全的方式钻更大的洞像这样。

On the other side of the box, you need a small hole to allow 3 wires to run from the controller to the strip. You can set the box and aluminum channel with the end cap with the hole on a table to get the right height for the hole.

一旦两个孔都设置好了,下一步就是准备LED条。

第3步:将条带布线

LED将提供5v直流电。CPU也将有5v,但它是一个3.3v的设备,并有一个内部调节器。诀窍在于,从CPU到LED条的数据线将为3.3v,LED可能会工作,但有时会闪烁,因为根据LED规范,电压有点低。下面是一个扩展讨论上一个可指示的

对于这个项目,我们将保持5v电源,而不是修改颜色来控制电流的使用。你可以使用一个水平移动器,后面会有更多关于它的信息。

不过,在这个项目中,新的技巧是使用一个二极管将第一个LED的电压稍微降低,然后用那个二极管驱动其余的LED。本文讨论了这种“牺牲型领导”的方法在这里在这里。Note that we will still be using that first LED, but it will be very slightly dimmer - mostly unnoticeable. This is a very compact solution to the problem, and only requires a single diode to work.

因此,对于这条带,我们将切断第一条LED,并将第一条LED与其他LED分开一小段距离。数据线和Gnd线只有一根跨接导线。然后+5红色导线将通过二极管连接到第二个LED背部到第一个LED。这样,第一个LED将具有5v-~0.8v(二极管正向电压)=~4.2v作为电源,这在数据线和电源线LED的70%建议范围内。第一个LED将以4.2v的电压将数据传输给其余的LED,因此所有其余的LED都可以以5v的电压运行。

This approach leaves that short gap distance between the first and second LEDs so they are not spaced exactly the same as the others. It's not very obvious unless you are looking for it. I think this is the easiest way to wire it, but I did try a different approach. For that, I cut off a slice from the end of the first LED so that there was still a gap, but the LED to LED spacing would remain. That one requires the Gnd and Data lines to have a jumper fromthe front第一个LED的第二个,所以它有点多线,但确实工作-见图片。

完成后,LED可以放置在通道中。

LED条带应有双面胶带,以便它可以安装到通道。测试适合它首先刚刚获得位置 - 您需要少量的房间为端盖。将一小块胶带放在第一夫妇LED下,在那里焊接电线将使焊接接头隔热,以防万一。确保将LED条的输入侧与控制器的框旁边。

You can now add the cover and end caps, but since they slide on, you only need the end cap with the hole for now. The box can now be attached to the channel with the 6" piece piece of aluminum bar. Cut a 6" piece of double sided foam tape and attach it to the bar. I cut a notch in the tape where the box has a ridge on the edge (see pictures). Run the wires into the box, and mount the box to the channel.

我使用标签制作者在千斤顶下制作一个小的5V标签,以避免未来的混乱。

步骤4:接线CPU

将连接器连接到控制器板的方法有两种。一种是将电线直接焊接到电路板上,用于一个相当永久的项目。您也可以焊接推动连接器的结束,并只需推动那些在头引脚上的董事会。

电源插孔+5和地面连接到带材电源和控制器电源。如果使用其他控制器,请确保它接受5V电源。最好将电容器添加到电源 - 类似1000 UF电解的电容器。这是推荐用于LED的LED,因为它们可以容易受到墙壁适配器的电源浪涌。在电源千斤顶上,较长的别针是外地。值得证实与你的。

最后一个连接是从控制器数据输出引脚到LED条上的数据输入引脚。我用了一个330欧姆的电阻串联在一起以减少线路中的噪音。电容器和电阻器的使用在许多LED项目现场如新苹果Ü柏吉德

Step 5: Programming

The following code was used in the video in the Introduction step. It was a basic test of moving a dot between three of the bars. It's mostly a copy of the sample code and is not very elegant.

在设置功能中,我们订阅来自其他led条带的led\u\u切换消息。现在,每当另一个strip发布该消息时,myHandler函数就会运行。

在循环中,基本思想是dot_pos变量将从0步进到29(条带中有30个LED)。当它到达结尾时,它将为下一个连续剧发布一条消息。该消息是下一个条带的id,对于示例代码,这是中间的条带(#2),因此下一个条带是#3,或“003”。如果dot_pos=255,那么我们只是在等待。

In the message handler for messages received, we simply check to see if the id is for us (in this case #2, or "002"), and if so, set the dot_pos to zero for the Loop to move along.

这是 - 非常简单,你可以看到发布和订阅有多简单。

This code is very simple - the hard coded IDs need to be changed for each strip, which is not hard, and the advantage is that they will always be in the same order. Another approach would be to have them auto-discover each other, but that will take more code to deal with timing issues. Another Instructable!

*这是一个最小的示例,请参阅extra-example.cpp for a version
* with more explantory documentation, example routines, how to * hook up your pixels and all of the pixel types that are supported. * */

#include“application.h”#include“neopixel / neopixel.h”

SYSTEM_MODE(AUTOMATIC);

// IMPORTANT: Set pixel COUNT, PIN and TYPE #define PIXEL_PIN D2 #define PIXEL_COUNT 30 #define PIXEL_TYPE WS2812B

uint8\u t dot\u pos=0;uint16\u t wait=50;

Adafruit\u NeoPixel strip=Adafruit\u NeoPixel(像素计数、像素针、像素类型);

void setup(){strib.begin();strib.show();//将所有像素初始化为“关闭”粒子.subscribe(“LED_mesh_handoff”,MyHandler);

}void loop(){uint16\t i,j;如果(点位置)=255){表示(i=0;iParticle.publish("led_mesh_handoff","003");dot_pos = 255; //delay(1000); } else { // delay if we are not switching to a new strip delay(wait); } } } // loop

//现在为MyHandler函数,当云告诉我们我们的Buddy的活动发布时调用。void myhandler(const char *事件,const char * data){// spark.subscribe处理程序是缺点函数,这意味着它们不会返回任何内容。//他们采取两个变量 - 您的活动的名称以及与您的活动一起使用的任何数据。//在这种情况下,事件将是“buddy_unique_event_name”,数据将是“完整”或“破损”// //,因为这里的输入是一个char,我们无法执行// data ==“完整”//或// data ==“破碎”

//chars就是不这么玩。相反,我们将使用strcmp(),它比较两个字符。//如果它们相同,strcmp将返回0。if(strcmp(data,“002”)==0){dot_pos = 0;}

//if (strcmp(data,"intact")==0) { // if your buddy's beam is intact, then turn your board LED off //digitalWrite(boardLed,LOW); //} //else if (strcmp(data,"broken")==0) { // if your buddy's beam is broken, turn your board LED on //digitalWrite(boardLed,HIGH); //} //else { // if the data is something else, don't do anything. // Really the data shouldn't be anything but those two listed above. //} } // myHandler

第6步:电平移位器变体

该项目的第一个原型使用SN74HCT125N电平移位器,使3.3V LED数据线控线控制从火花芯上控制,最高可达LED条带来的。最后,不需要此较大的盒子和零件,但构建图片可能对框中需要更多电路的其他项目有用。我使用了一条宽的酒吧并将其切成框架和条带匹配的形状。

第七步:小饰品变型

You can also use a small controller without Wifi, like the Adafruit Trinket. The mounting and connections are about the same, and the idea is to just have a fixed pattern running for holiday or party lighting that can be easily moved and setup. The channels come with mounting clips to make seasonal setup easier.

You could add a switch to change the lighting modes. See the next step for an example.

第8步:安装在中间变体中

另一个测试是山中间的盒子of the strip to keep the ends clear. In the pictures the box is also painted white (did not get around to painting the lid). To run the wires, a hole was drilled in the strip and the middle of the box bottom. The power wires can just be connected to the LED strip in the middle, and the data wire is run along the side to the start of the strip. I can't say this is a great place to mount the box - perhaps in certain situations it would make sense.

图片还显示了一个未连接的按钮,但可用于切换模式或其他东西。

灯竞赛2017年

参加了
灯竞赛2017年

2017年事物竞赛互联网

参加了
2017年事物竞赛互联网

Be the First to Share

    Recommendations

    • Pi日速度挑战

      Pi日速度挑战
    • 垃圾到宝藏竞赛

      垃圾到宝藏竞赛
    • Microcontroller Contest

      Microcontroller Contest

    评论