"""If the switch is to the right, it will appear that nothing is happening. Move the switch to the left to see the NeoPixels light up in colors related to the accelerometer! The CPX has an accelerometer in the center that returns (x, y, z) acceleration values. This program uses those values to light up the NeoPixels based on those acceleration values.""" from adafruit_circuitplayground.express import cpx # Main loop gets x, y and z axis acceleration, prints the values, and turns on # red, green and blue, at levels related to the x, y and z values. while True: if not cpx.switch: # If the switch is to the right, it returns False! print("Slide switch off!") cpx.pixels.fill((0, 0, 0)) continue else: R = 0 G = 0 B = 0 x, y, z = cpx.acceleration print((x, y, z)) cpx.pixels.fill(((R + abs(int(x))), (G + abs(int(y))), (B + abs(int(z)))))