[Python] Code for measuring ambient light RGB of APDS9960

I made it because I didn't have the sample code to check RGB.

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

[Python] Code for measuring ambient light RGB of APDS9960
Code for checking the operation of Python Matplotlib
Python code memo for yourself
2.x, 3.x character code of python
Implementation of Light CNN (Python Keras)
Introductory table of contents for python3
Record of Python introduction for newcomers
Code reading of Safe, a library for checking password strength in Python
Example of python code for exponential distribution and maximum likelihood estimation (MLE)
Installation of Visual studio code and installation of python
[Python] Minutes of study meeting for beginners (7/15)
Summary of various for statements in Python
[Python3] Rewrite the code object of the function
python> coding guide> PEP 0008 --Style Guide for Python Code
Pandas of the beginner, by the beginner, for the beginner [Python]
A tool for easily entering Python code
Summary of useful techniques for Python Scrapy
[Python] Get the character code of the file
R code compatible sheet for Python users
[Python] Read the source code of Bottle Part 2
The story of low learning costs for Python
[Python] [chardet] Automatic detection of character code of file
[Python] Read the source code of Bottle Part 1
Image processing? The story of starting Python for
Easy understanding of Python for & arrays (for super beginners)
Links and memos of Python character code strings
Summary of frequently used Python arrays (for myself)
List of Python code to move and remember
Convert the character code of the file with Python3
Settings for Python coding in Visual Studio Code
Static analysis of Python code with GitLab CI
[Python for Hikari] Chapter 09-01 Classes (Basics of Objects)
[Blender x Python] Think of code with symbols
[Visual Studio Code] [Python] Tasks.json + problemMatcher settings for Python
Basic story of inheritance in Python (for beginners)