Micropython学习交流群 学习QQ群:786510434 提供多种固件下载和学习交流。
Micropython-扇贝物联 QQ群:31324057 扇贝物联是一个让你与智能设备沟通更方便的物联网云平台
Micropython学习交流群 学习QQ群:468985481 学习交流ESP8266、ESP32、ESP8285、wifi模块开发交流、物联网。
Micropython老哥俩的IT农场分享QQ群:929132891 为喜欢科创制作的小白们分享一些自制的计算机软硬件免费公益课程,由两位多年从事IT研发的中年大叔发起。
micropython esp32s3 neopixel WS2812 LED
import network import time import urequests from machine import Pin from neopixel import NeoPixel from random import randint #NeoPixel Setup neopin = Pin(48, Pin.OUT) pixels = 25 np = NeoPixel(neopin, pixels) #Weather Icons sun = [2,6,7,8,10,11,12,13,14,16,17,18,22] cloudy = [7,11,12,13,15,16,17,18,19] rain_cloud = [7,11,12,13,15,16,17,18,19] rain1 = [0,4,5,9,10,12,14,17,22] rain2 = [2,7,10,12,14,15,19,20,24] lightning_cloud = [2,6,7,8,10,11,12,13,14,16,18,20,22] lightning = [3,7,11,12,13,17,21] snow_ice = [0,2,4,7,10,11,12,13,14,17,20,22,24] fail = [0,4,6,8,12,16,18,20,24] fail2 = [2,7,10,11,12,13,14,17,22] #Wi-Fi Setup """ wlan = network.WLAN(network.STA_IF) wlan.active(True) wlan.connect("NBWIFI", "xxxxx") time.sleep(5) print(wlan.isconnected()) print(wlan.ifconfig()) if wlan.isconnected() == True: for i in range(3): np.fill((0,16,0)) np.write() time.sleep(0.1) np.fill((0,0,0)) np.write() time.sleep(0.1) else: for i in range(3): np.fill((16,0,0)) np.write() time.sleep(0.1) np.fill((0,0,0)) np.write() time.sleep(0.1) time.sleep(3) """ print("start...") while True: #Get the weather data #r = urequests.get("http://api.openweathermap.org/data/2.5/weather?q=Blackpool,UK&appid=--YOUR OPEN WEATHER MAP API KEY HERE--").json() #weather = r["weather"][0]["main"] #Change the weather here to test the conditional tests. #weather = "Cats and dogs" weather = "Clouds" print(weather) if weather == "Clear": for value in sun: np[value] = (255,265,0) np.write() time.sleep(10) np.fill((0,0,0)) np.write() elif weather == "Clouds": for value in cloudy: print(value) np[value] = (8,8,8) np.write() time.sleep(10) np.fill((0,0,0)) np.write() elif weather == "Rain": for i in range(10): for value in rain1: np[value] = (0,8,8) np.write() time.sleep(0.5) np.fill((0,0,0)) np.write() for value in rain2: np[value] = (0,8,8) np.write() time.sleep(0.5) np.fill((0,0,0)) np.write() elif weather == "Thunderstorm": for i in range(10): for value in lightning_cloud: np[value] = (8,8,8) np.write() time.sleep(0.5) np.fill((0,0,0)) np.write() for value in lightning: np[value] = (8,8,0) np.write() time.sleep(0.5) np.fill((0,0,0)) np.write() elif weather == "Snow": for value in snow_ice: np[value] = (0,8,8) np.write() time.sleep(10) np.fill((0,0,0)) np.write() else: print("No Weather Data") for i in range(10): for value in fail: np[value] = (128,0,0) np.write() time.sleep(0.5) np.fill((0,0,0)) np.write() for value in fail2: np[value] = (128,0,0) np.write() time.sleep(0.5) np.fill((0,0,0)) np.write() time.sleep(10)
Copyright © 2014 ESP56.com All Rights Reserved
执行时间: 0.0079028606414795 seconds