Simple test¶
Ensure your device works with this simple test.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | # Simple demo of the TCS34725 color sensor.
# Will detect the color from the sensor and print it out every second.
import time
import board
import busio
import adafruit_tcs34725
# Initialize I2C bus and sensor.
i2c = busio.I2C(board.SCL, board.SDA)
sensor = adafruit_tcs34725.TCS34725(i2c)
# Main loop reading color and printing it every second.
while True:
# Read the color temperature and lux of the sensor too.
temp = sensor.color_temperature
lux = sensor.lux
print("Temperature: {0}K Lux: {1}".format(temp, lux))
# Delay for a second and repeat.
time.sleep(1.0)
|