forked from FAR-Lab/Interactive-Lab-Hub
-
Notifications
You must be signed in to change notification settings - Fork 0
/
color_test.py
30 lines (23 loc) · 801 Bytes
/
color_test.py
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
# SPDX-FileCopyrightText: 2021 ladyada for Adafruit Industries
# SPDX-License-Identifier: MIT
import time
import board
from adafruit_apds9960.apds9960 import APDS9960
from adafruit_apds9960 import colorutility
i2c = board.I2C()
apds = APDS9960(i2c)
apds.enable_color = True
while True:
# create some variables to store the color data in
# wait for color data to be ready
while not apds.color_data_ready:
time.sleep(0.005)
# get the data and print the different channels
r, g, b, c = apds.color_data
print("red: ", r)
print("green: ", g)
print("blue: ", b)
print("clear: ", c)
print("color temp {}".format(colorutility.calculate_color_temperature(r, g, b)))
print("light lux {}".format(colorutility.calculate_lux(r, g, b)))
time.sleep(0.5)