import machine
import time
# 闪烁指示灯
def blink():
led = machine.Pin(2, machine.Pin.OUT)
led.off()
while True:
led.on()
time.sleep(0.5)
led.off()
time.sleep(0.5)
print('blink....')
# 连接WiFi
def netClient():
import network
wlan = network.WLAN(network.STA_IF) # create station interface
wlan.active(True) # activate the interface
wlan.scan() # scan for access points
wlan.isconnected() # check if the station is connected to an AP
if not wlan.isconnected():
print('connecting to network...')
wlan.connect('这里填写要连接的WiFi名称', 'WiFi密码') # connect to an AP
while not wlan.isconnected():
pass
print('network config:', wlan.ifconfig())
s = wlan.config('mac') # get the interface's MAC adddress
ap = network.WLAN(network.AP_IF) # create access-point interface
ap.active(True) # activate the interface
ap.config(essid='ESP-AP') # 开启一个热点
blink()
netClient()