/ Labo_RC_Car_Light_FX / code.py
code.py
1 # SPDX-FileCopyrightText: 2018 Collin Cunningham for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 import board 6 import neopixel 7 from adafruit_circuitplayground.express import cpx 8 9 pixels = neopixel.NeoPixel(board.NEOPIXEL, 10, brightness=0.1, auto_write=True) 10 pixels.fill(0) 11 12 while True: 13 14 x, y, z = cpx.acceleration # read acceleromter 15 r, g, b = 0, 0, 0 16 17 if abs(x) > 4.0: 18 r = 255 19 if abs(y) > 2.0: 20 g = 255 21 if z > -6.0 or z < -12.0: 22 b = 255 23 24 pixels.fill((r, g, b))