from microbit import *
import radio
radio.config(group=17)
compass.calibrate()
radio.on()
while True:
if button_a.was_pressed():
display.scroll(compass.get_field_strength())
if compass.get_field_strength() < 100000:
display.show(Image.DIAMOND_SMALL)
radio.send('door open')
else:
display.clear()
radio.send('door closed')
sleep(2000)
报警端代码:
from microbit import *
import music
import radio
radio.config(group=17)
radio.on()
while True:
message = radio.receive()
if message:
if message == 'door open':
display.show(Image.NO)
music.play(["C4:4"])
if message == 'door closed':
display.show(Image.YES)
# Python uses nanoteslas to measure magnetism.
# Experiment with different numbers depending on the
# strength of your magnet, which you can read by
# pressing button A.
from microbit import *
while True:
if button_a.was_pressed():
display.scroll(compass.get_field_strength())
if compass.get_field_strength() < 200000:
display.show(Image.ANGRY)
确保wlansvc服务启动中,没有无线网络的台式机,该服务未启动 $ sc query wlansvc | findstr STATE STATE : 4 RUNNING
查看曾经连接过的无线网络 $ netsh wlan show profiles … User profiles All User Profile : any All User Profile : some All User Profile : meeting_5GHz All User Profile : meeting_2.4GHz
若wlansvc服务未启动,上述命令报错 $ netsh wlan show profiles The Wireless AutoConfig Service (wlansvc) is not running.