code.py
1 # SPDX-FileCopyrightText: 2018 Kattni Rembor for Adafruit Industries 2 # 3 # SPDX-License-Identifier: MIT 4 5 from adafruit_circuitplayground.express import cpx 6 7 # Main loop gets x, y and z axis acceleration, prints the values, and turns on 8 # red, green and blue, at levels related to the x, y and z values. 9 while True: 10 if cpx.switch: 11 print("Slide switch off!") 12 cpx.pixels.fill((0, 0, 0)) 13 continue 14 R = 0 15 G = 0 16 B = 0 17 x, y, z = cpx.acceleration 18 print((x, y, z)) 19 if x: 20 R = R + abs(int(x)) 21 if y: 22 G = G + abs(int(y)) 23 if z: 24 B = B + abs(int(z)) 25 cpx.pixels.fill((R, G, B))