from mpython import * import time import neopixel my_rgb = neopixel.NeoPixel(Pin(Pin.P13), n=24, bpp=3, timing=1) p2 = MPythonPin(2, PinMode.IN) image_picture = Image() night = 0 rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) while True: print(night) night = p2.read_digital() oled.fill(0) oled.blit(image_picture.load("face/003.pbm", 1), 0, 0) oled.blit(image_picture.load("face/4.pbm", 1), 0, 20) oled.show() if night == 1: my_rgb.fill( (255, 50, 0) ) my_rgb.write() rgb.fill( (int(255), int(0), int(0)) ) rgb.write() time.sleep_ms(1) time.sleep(1) else: rgb.fill( (0, 0, 0) ) rgb.write() time.sleep_ms(1) my_rgb.fill( (0, 0, 0) ) my_rgb.write() oled.DispChar("掌控感应小夜灯", 16, 16, 1)