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