''' Mission 12 - Night Light The program uses the light sensor to make CodeX act as a night light. It will gradually brighten the pixels as the light reading gets darker, or turn off pixels if there is light. Concepts learned: reading from the light sensor, using pixels.fill() to set all pixels one color, using the argument brightness to control the pixel brightness ''' from codex import * from time import sleep # select a value slightly under the # room light readings ROOM = 5500 while True: value = light.read() if value < ROOM: scaled = (1 - value / ROOM) * 20 level = int(scaled) pixels.fill(WHITE, brightness = level) else: pixels.fill(BLACK)