''' Mission 12 - Night Light Spicy Solution The remix gives has 5 levels for the night light. Set values for four different light intensities. Use multiple branches in the if statement for each intensity. The order of the branches is very important! If using <, start with smallest and go to largest. NOTE: This solution uses the math for dim level for each branch. This is optional. Students could just set the color and brightness. The choice of displaying an image is also optional. ''' from codex import * from time import sleep # select a value slightly under the # room light readings BRIGHT = 7000 ROOM = 5500 SEMI_DARK = 3000 DARK = 800 while True: value = light.read() # darkest value if value < DARK: scaled = (1 - value / ROOM) * 20 level = int(scaled) pixels.fill(WHITE, brightness = level) display.show(pics.ASLEEP) # next darkest value elif value < SEMI_DARK: scaled = (1 - value / ROOM) * 20 level = int(scaled) pixels.fill(YELLOW, brightness = level) display.show(pics.HEART_SMALL) # room value elif value < ROOM: scaled = (1 - value / ROOM) * 20 level = int(scaled) pixels.fill(GREEN, brightness = level) display.show(pics.HAPPY) # brighter than room value elif value < BRIGHT: scaled = (1 - value / ROOM) * 20 level = int(scaled) pixels.fill(RED, brightness = level) display.show(pics.TARGET) # very bright (flashlight) else: pixels.fill(BLACK) display.show(pics.HOUSE)