0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Python】APDS9960の環境光RGBを測定するコード

Last updated at Posted at 2019-10-31

RGBを調べるサンプルコードがなかったので作りました。

今回は、こちらのライブラリを使っています。
https://github.com/liske/python-apds9960
今回はMicroPythonではないプログラムです。

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") 

他の事もしたいという人は、このコードを見てみてください。
https://github.com/liske/python-apds9960/blob/master/apds9960/device.py

0
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?