This time, I'm using this library. https://github.com/liske/python-apds9960 This time it's a non-MicroPython program.
from apds9960.const import *
from apds9960 import APDS9960
import RPi.GPIO as GPIO
import smbus
from time import sleep
port = 1
bus = smbus.SMBus(port)
apds = APDS9960(bus)
try:
apds.enableLightSensor()
oval = -1
print("LoggingStart")
while True:
sleep(0.1)
print("RedLight={}".format(apds.readRedLight()))
print("GreenLight={}".format(apds.readGreenLight()))
print("BlueLight={}".format(apds.readBlueLight()))
finally:
GPIO.cleanup()
print ("Bye")
If you want to do other things, take a look at this code. https://github.com/liske/python-apds9960/blob/master/apds9960/device.py
Recommended Posts