Toggle Navigation
Hatchery
Eggs
Brightness Warning.
brightness.py
Users
Badges
Login
Register
MCH2022 badge?
go to mch2022.badge.team
brightness.py
raw
Content
#import leds import utime import display import light_sensor #import humidity_sensor import vibra import os disp = display.open() filename = "brightness.txt" if filename not in os.listdir("."): disp.clear() disp.print("No file! Create 'brightness' with value") disp.update() while True: utime.sleep(10) os.exit() file = open(filename, "r") max_value = file.readline() file.close() #max_value = "150" max_value = int(max_value) while True: disp.clear() light_value = light_sensor.get_reading() if light_value > max_value: disp.print("Brightness alarm {}".format(light_value)) disp.update() vibra.vibrate(100) utime.sleep(1) vibra.vibrate(100) else: disp.print("Light: {}".format(light_value)) disp.update() utime.sleep(1)