-
Notifications
You must be signed in to change notification settings - Fork 0
/
Custom Visualizer
43 lines (37 loc) · 1.08 KB
/
Custom Visualizer
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import board
import busio
import adafruit_apds9960.apds9960
import neopixel
import time
import analogio
import digitalio
import usb_hid
from adafruit_hid.mouse import Mouse
mouse = Mouse(usb_hid.devices)
i2c = board.STEMMA_I2C()
pixels = neopixel.NeoPixel(board.NEOPIXEL, 1)
x_axis = analogio.AnalogIn(board.A0)
y_axis = analogio.AnalogIn(board.A1)
select = digitalio.DigitalInOut(board.A2)
select.direction = digitalio.Direction.INPUT
select.pull = digitalio.Pull.UP
sensor = adafruit_apds9960.apds9960.APDS9960(i2c)
sensor.enable_color = True
sensor.color_integration_time = 50
pot_min = 0.00
pot_max = 3.29
step = (pot_max - pot_min) / 20.0
while True:
while sensor.color_data_ready:
r, g, b, c = sensor.color_data
print('Red: {0}, Green: {1}, Blue: {2}, Clear: {3}'.format(r, g, b, c))
if c < 100:
# print(steps(x))
mouse.move(y=0)
elif c >= 4000:
# print(steps(x))
mouse.move(y=-10)
if r >= 100 and b <= 200:
mouse.move (x=-20)
elif r >= 100 and b >= 250:
mouse.move (x=20)