Skip to content

Commit

Permalink
Source added
Browse files Browse the repository at this point in the history
  • Loading branch information
brittanybull committed Jul 23, 2018
1 parent 323544e commit 1de4a47
Show file tree
Hide file tree
Showing 3 changed files with 171 additions and 0 deletions.
Binary file added .DS_Store
Binary file not shown.
106 changes: 106 additions & 0 deletions color_sensorCC03_CS11/color_sensorCC03_CS11.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
/***************************************************************************
This is a library for the APDS9960 digital proximity, ambient light, RGB, and gesture sensor
This sketch puts the sensor in color mode and reads the RGB and clear values.
Designed specifically to work with the Adafruit APDS9960 breakout
----> http://www.adafruit.com/products/3595
These sensors use I2C to communicate. The device's I2C address is 0x39
Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
Written by Dean Miller for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/

#include "Adafruit_APDS9960.h"
#include <xCore.h>
#include <xOD01.h>

#if defined(ESP8266)
#define RED RED
#define GREEN GREEN
#define BLUE BLUE
#include <ESP8266WiFi.h>
#define Serial Serial

#elif defined(ARDUINO_SAMD_ZERO)
#define RED CC03_RED
#define GREEN CC03_GREEN
#define BLUE CC03_BLUE
#define Serial SerialUSB

#elif defined(ARDUINO_AVR_PRO)
#define RED CC01_RED
#define GREEN CC01_GREEN
#define BLUE CC01_BLUE
#define Serial Serial

#elif defined(ESP32)
#define RED CW02_RED
#define GREEN CW02_GREEN
#define BLUE CW02_BLUE
#define Serial Serial
#endif

Adafruit_APDS9960 apds;

void setup() {

#if defined(ESP8266)
WiFi.forceSleepBegin();
Wire.begin(2, 14);
Wire.setClockStretchLimit(15000);

#elif defined(ARDUINO_SAMD_ZERO)
Wire.begin();

#elif defined(ARDUINO_AVR_PRO)
Wire.begin();

#elif defined(ESP32)
Wire.begin();

#endif

OLED.begin();
Serial.begin(115200);

if(!apds.begin()){
OD01.println("failed to initialize device! Please check your wiring.");
}
else OD01.println("Device initialized!");

//enable color sensign mode
apds.enableColor(true);
}

void loop() {
//create some variables to store the color data in
uint16_t r, g, b, c;

//wait for color data to be ready
while(!apds.colorDataReady()){
delay(5);
}

//get the data and print the different channels
apds.getColorData(&r, &g, &b, &c);
OD01.print("red: ");
OD01.println(r);

OD01.print(" green: ");
OD01.println(g);

OD01.print(" blue: ");
OD01.println(b);

OD01.print(" clear: ");
OD01.println(c);
OD01.println();

delay(500);
}
65 changes: 65 additions & 0 deletions color_sensorCW01/color_sensorCW01.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
/***************************************************************************
This is a library for the APDS9960 digital proximity, ambient light, RGB, and gesture sensor
This sketch puts the sensor in color mode and reads the RGB and clear values.
Designed specifically to work with the Adafruit APDS9960 breakout
----> http://www.adafruit.com/products/3595
These sensors use I2C to communicate. The device's I2C address is 0x39
Adafruit invests time and resources providing this open source code,
please support Adafruit andopen-source hardware by purchasing products
from Adafruit!
Written by Dean Miller for Adafruit Industries.
BSD license, all text above must be included in any redistribution
***************************************************************************/

#include "Adafruit_APDS9960.h"
#include <xCore.h>
#include <xOD01.h>

Adafruit_APDS9960 apds;

void setup() {

Wire.begin(2, 14);
OLED.begin();
Serial.begin(115200);

if(!apds.begin()){
OD01.println("failed to initialize device! Please check your wiring.");
}
else OD01.println("Device initialized!");

//enable color sensign mode
apds.enableColor(true);
}

void loop() {
//create some variables to store the color data in
uint16_t r, g, b, c;

//wait for color data to be ready
while(!apds.colorDataReady()){
delay(5);
}

//get the data and print the different channels
apds.getColorData(&r, &g, &b, &c);
OD01.print("red: ");
OD01.println(r);

OD01.print(" green: ");
OD01.println(g);

OD01.print(" blue: ");
OD01.println(b);

OD01.print(" clear: ");
OD01.println(c);
OD01.println();

delay(500);
}

0 comments on commit 1de4a47

Please sign in to comment.