本帖最后由 602293544 于 2019-11-25 23:09 编辑
先上图
需要的东西:esp12e、ws2812-16、继电器、自复位开关(自带的是自锁的,然后去掉了里面的一个小东西变成自复位的了)
买来的时候拆开一看里面的空间有点小,放不下块头这么大的继电器模块,想着就用这个
继电器讲究一下吧,仔细想想,不是还有个电池盒嘛,这么对我没啥用拆了拆了有空间了
继电器用来控制马达,实现旋转效果
2个自复位(不是我不想只用一个,他本来带的就是2个要物尽其用(好吧是我不会弄只能2个)),一个控制灯颜色切换(这个特效切换不会玩官方说 明看不懂,我就想按顺序切换这些effects,有大佬指点指点嘛(我想嫖代码)),另一个控制旋转(单机)和 音乐(双击),长按关闭(2个都有的功能)
下面是esphome的代码
substitutions:
device_name: xuanzhuan
wifi_ssid: 'PDCN'
wifi_password: '12345678'
wifi_fast_connect: 'false'
wifi_reboot_timeout: 0s
ota_password: '123456'
api_reboot_timeout: 0s
esphome:
name: $device_name
platform: ESP8266
board: esp01_1m
web_server:
port: 80
css_url: https://esphome.io/_static/webserver-v1.min.css
js_url: https://esphome.io/_static/webserver-v1.min.js
wifi:
ssid: $wifi_ssid
password: $wifi_password
reboot_timeout: $wifi_reboot_timeout
power_save_mode: none
fast_connect: $wifi_fast_connect
logger:
api:
reboot_timeout: $api_reboot_timeout
ota:
safe_mode: true
password: $ota_password
globals:
- id: lt
type: int
restore_value: no
initial_value: '0b000'
- id: red
type: int
restore_value: no
initial_value: '0'
- id: green
type: int
restore_value: no
initial_value: '0'
- id: blue
type: int
restore_value: no
switch:
- platform: restart
name: "xuanzhuan_res"
- platform: gpio
name: "xuanzhuan_switch"
id: dianji
pin:
number: GPIO13
- platform: gpio
name: "xuanzhuan_yinyue"
id: yinyue
pin:
number: GPIO16
sensor:
- platform: wifi_signal
name: "xuanzhuan_rssi"
update_interval: 60s
#ws2812灯带
light:
- platform: fastled_clockless
chipset: WS2811
pin: GPIO12
id: w_led
num_leds: 16
rgb_order: GRB
name: "WS2811_Light"
effects:
- addressable_rainbow:
- addressable_color_wipe:
- addressable_scan:
- addressable_twinkle:
- addressable_random_twinkle:
- addressable_fireworks:
- addressable_flicker:
binary_sensor:
- platform: gpio
name: "xuanzhuan_button" (这个按钮嫖来的,<a href="https://bbs.hassbian.com/home.php?mod=space&uid=800" target="_blank" class="xw1" style="color: rgb(51, 51, 51); text-decoration-line: none; font-weight: 700; font-size: 12px; background-color: rgb(229, 237, 242);">trz0332</a>这个大佬的)
效果图,有点小毕竟限制5m
没了
|