杭一鸣 • 24天前
from mpython import *
from bluebit import *
import parrot
sht20 = SHT20() while True:
oled.fill(0)
oled.DispChar(str('按下P键显示厕所位置'), 0, 0, 1)
oled.DispChar(str('按下Y键显示主场馆位置'), 0, 16, 1)
oled.DispChar(str('按下P键显示出口位置'), 0, 32, 1)
oled.DispChar(str(('当前温度' + str(sht20.temperature()))), 0, 48, 1)
if touchpad_p.is_pressed():
oled.fill(0)
oled.DispChar(str('厕所在南面100米'), 0, 0, 1)
oled.show()
elif touchpad_y.is_pressed():
oled.fill(0)
oled.DispChar(str('主场馆在北面50米'), 0, 0, 1)
oled.show()
elif touchpad_t.is_pressed():
oled.fill(0)
oled.DispChar(str('出口在西面150米'), 0, 0, 1)
oled.show()
oled.show()
if sht20.temperature() > 30:
parrot.set_speed(parrot.MOTOR_1, -100)
else:
parrot.set_speed(parrot.MOTOR_1, 0)
if light.read() < 2000:
parrot.set_speed(parrot.MOTOR_2, -50)
else:
parrot.led_off(parrot.MOTOR_2)
评论: