完善资料让更多小伙伴认识你,还能领取20积分哦, 立即完善>
这个项目有更多的帖子并且已经重新启动了一段时间。现在还有视频教程解释一切,从您需要哪些组件到如何使用 QuinLED 板和 ESP-01 进行焊接、闪烁和编程。如果您对小型且易于完成的项目感兴趣,并且随后拥有 WiFi 可控 LED 灯条,那么这就是给您的!
版考虑构建我自己的网络控制 LED 驱动器/调光模块来运行我家中的 LED 灯条。最终结果应该是我连接到 LED 灯条的模块,然后通过 WiFi 控制它们。我使用 Domoticz 作为 Domotica 系统。 其中的一个“特殊”要求是灯绝不能立即打开或关闭,而是始终在新设置的值之间逐渐变暗。褪色必须在“硬件”中完成,所有其他控制都使用 Domoticz 完成。他们提供了一个带有滑块和作品的漂亮界面。 在将 Arduino Nano 与 RM04(串行 WiFi 桥接器)耦合后,我的工作非常完美。我对 Arduino 和 Domoticz 端都进行了编程,我的原型已经运行了几个月,没有失败!我正准备为此制作定制 PCB 并创建实际模块……然后 ESP8266 出现了! ESP8266 的成本约为 4 到 5 美元,具体取决于所需的引脚,带有内置天线!相比之下,Arduino Nano 的成本为 4 美元,而 RM04 的成本约为 10 美元,总计 14 美元!如果我能让它工作的话,在这里可以节省大量成本。 所以在修补了 2 个晚上并克服了一些障碍之后,它的第一部分似乎起作用了!我目前使用的是 NodeLUA Build 20141222 固件。 代码:全选-- Setup WiFi connection wifi.setmode(wifi.STATION) wifi.sta.config("SSID","PASSSSSS") print(wifi.sta.getip()) -- Setup initial value and enable LED pin(s) pwm.setup(3, 400, 010) pwm.start(3) -- Loop for running LED's from PWM value 0 to PWM value 1000 in steps of 1 including a delay to slow down fade and using tmr.wdclr() to prevent the hardware watchdog killing the fade for i = 0, 1000, 1 do pwm.setduty(3, i) tmr.delay(12500) tmr.wdclr() end pwm.setup(4, 1000, 005) pwm.start(3) pwm.start(4) LED1_current=005 LED1_target=005 LED2_current=005 LED2_target=005 Fadetime1=5000 Fadetime2=5000 Stepcounter1=0 PosStepcounter1=0 DimTimer1=0 Stepcounter2=0 PosStepcounter2=0 DimTimer2=0 wifi.setmode(wifi.STATION) wifi.sta.config("SSID","PASSSSS") srv=net.createServer(net.TCP) srv:listen(43333,function(conn) conn:on("receive",function(conn,payload) print("Input:"..payload) if string.find(payload,"LED1") then LED1_target=tonumber(string.sub(payload, 13) ) print("Received LED1 Target Value: "..LED1_target) Stepcounter1=(LED1_target)-(LED1_current) if (Stepcounter1) < 0 then PosStepcounter1=(Stepcounter1)*-1 else PosStepcounter1=(Stepcounter1) end if (PosStepcounter1) == 0 then PosStepcounter1=(PosStepcounter1)+1 else PosStepcounter1=(PosStepcounter1) end DimTimer1=(Fadetime1)/(PosStepcounter1) if (DimTimer1) == 0 then DimTimer1=(DimTimer1)+1 else DimTimer1=(DimTimer1) end print (Fadetime1) print (Stepcounter1) print (PosStepcounter1) print (DimTimer1) print (LED1_current) print (LED1_target) tmr.alarm(0, (DimTimer1), 1, function() if LED1_current < LED1_target then LED1_current = (LED1_current + 1) pwm.setduty(3, LED1_current) elseif LED1_current > LED1_target then LED1_current = (LED1_current - 1) pwm.setduty(3, LED1_current) elseif LED1_current == LED1_target then tmr.stop(0) end end ) end if string.find(payload,"LED2") then print("Received LED2 Target Value") LED2_target=tonumber(string.sub(payload, 13) ) Stepcounter2=(LED2_target)-(LED2_current) if (Stepcounter2) < 0 then PosStepcounter2=(Stepcounter2)*-1 else PosStepcounter2=(Stepcounter2) end if (PosStepcounter2) == 0 then PosStepcounter2=(PosStepcounter2)+1 else PosStepcounter2=(PosStepcounter2) end DimTimer2=(Fadetime2)/(PosStepcounter2) if (DimTimer2) == 0 then DimTimer2=(DimTimer2)+1 else DimTimer2=(DimTimer2) end print (Fadetime2) print (Stepcounter2) print (PosStepcounter2) print (DimTimer2) print (LED2_current) print (LED2_target) tmr.alarm(1, (DimTimer2), 1, function() if LED2_current < LED2_target then LED2_current = (LED2_current + 1) pwm.setduty(4, LED2_current) elseif LED2_current > LED2_target then LED2_current = (LED2_current - 1) pwm.setduty(4, LED2_current) elseif LED2_current == LED2_target then tmr.stop(1) end end ) end end) end) print ("Booted to QuinLED_ESP8266_V0.4") |
|
相关推荐
|
|
只有小组成员才能发言,加入小组>>
191个成员聚集在这个小组
加入小组470 浏览 1 评论
1640 浏览 2 评论
641浏览 6评论
536浏览 5评论
有没有办法在不使用混杂模式的情况下实现Wifi驱动程序接收缓冲区访问中断呢?
515浏览 5评论
517浏览 4评论
507浏览 4评论
小黑屋| 手机版| Archiver| 电子发烧友 ( 湘ICP备2023018690号 )
GMT+8, 2025-2-22 22:05 , Processed in 0.878502 second(s), Total 74, Slave 58 queries .
Powered by 电子发烧友网
© 2015 bbs.elecfans.com
关注我们的微信
下载发烧友APP
电子发烧友观察
版权所有 © 湖南华秋数字科技有限公司
电子发烧友 (电路图) 湘公网安备 43011202000918 号 电信与信息服务业务经营许可证:合字B2-20210191