Nightlight A little tool to turn on a nightlight based off of a couple of factors a little graph showing sensor outputs over time enable: bool = False SOUND_LEVEL = 50 # set to higher value if ambiant sound_level is high. def on_forever(): control.wait_micros(3000) print("Sound level: " + input.sound_level()) print("Light level: " + input.light_level()) print("Button: " + input.logo_is_pressed()) roll = input.rotation(Rotation.ROLL) pitch = input.rotation(Rotation.PITCH) print(pitch) rotation_enable = (-160 <= roll <= 160) or (-160 <= pitch <= 160) enable = input.logo_is_pressed() or (((input.sound_level() >= SOUND_LEVEL) or (input.light_level() < 100)) and rotation_enable print("enable" + enable) if enable: basic.show_leds(""" # # # # # # # # # # # # # # # # # # # # # # # # # """) else: basic.clear_screen() basic.forever(on_forever)