楼主: 驴友花雕
|
[MP动手做] MicroPython动手做(21)——掌控板之磁场传感器 |
6、简易钱包防丢磁感应报警器(钱包里放置一块强磁片) 离开一段距离,磁场强度小于8,则声光报警 [mw_shl_code=applescript,false]#MicroPython动手做(21)——掌控板之磁场传感器 #简易钱包防丢磁感应报警器(钱包里放置一块强磁片) from mpython import * import time import music while True: magnetic.peeling() rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) oled.fill(0) oled.DispChar('磁场强度', 0, 16, 1) oled.DispChar((str(magnetic.get_field_strength())), 0, 32, 1) oled.show() if magnetic.get_field_strength() < 8: rgb.fill((int(255), int(0), int(0))) rgb.write() time.sleep_ms(1) music.pitch(523, 300) music.pitch(988, 300) else: music.stop() rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) time.sleep(1)[/mw_shl_code] |
© 2013-2024 Comsenz Inc. Powered by Discuz! X3.4 Licensed