GY-9960-3.3APDS-9960模塊,RGB紅外手勢傳感+感應運動方向識別模塊,供大家學習使用。
arduino源程序如下:
- /****************************************************************
- ColorSensor.ino
- APDS-9960 RGB and Gesture Sensor
- Shawn Hymel @ SparkFun Electronics
- October 15, 2014
- https://github.com/sparkfun/APDS-9960_RGB_and_Gesture_Sensor
- Tests the color and ambient light sensing abilities of the
- APDS-9960. Configures APDS-9960 over I2C and polls the sensor for
- ambient light and color levels, which are displayed over the
- serial console.
- Hardware Connections:
- IMPORTANT: The APDS-9960 can only accept 3.3V!
-
- Arduino Pin APDS-9960 Board Function
-
- 3.3V VCC Power
- GND GND Ground
- A4 SDA I2C Data
- A5 SCL I2C Clock
- Resources:
- Include Wire.h and SparkFun_APDS-9960.h
- Development environment specifics:
- Written in Arduino 1.0.5
- Tested with SparkFun Arduino Pro Mini 3.3V
- This code is beerware; if you see me (or any other SparkFun
- employee) at the local, and you've found our code helpful, please
- buy us a round!
- Distributed as-is; no warranty is given.
- ****************************************************************/
- #include <Wire.h>
- #include <SparkFun_APDS9960.h>
- #include <LiquidCrystal.h>
- // Global Variables
- SparkFun_APDS9960 apds = SparkFun_APDS9960();
- uint16_t ambient_light = 0;
- uint16_t red_light = 0;
- uint16_t green_light = 0;
- uint16_t blue_light = 0;
- LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
- void setup() {
-
- // set up the LCD's number of columns and rows:
- lcd.begin(16, 2);
- // Print a message to the LCD.
-
-
-
- // Initialize Serial port
- Serial.begin(9600);
- Serial.println();
- Serial.println(F("--------------------------------"));
- Serial.println(F("SparkFun APDS-9960 - ColorSensor"));
- Serial.println(F("--------------------------------"));
-
- // Initialize APDS-9960 (configure I2C and initial values)
- if ( apds.init() ) {
- Serial.println(F("APDS-9960 initialization complete"));
- } else {
- Serial.println(F("Something went wrong during APDS-9960 init!"));
- }
-
- // Start running the APDS-9960 light sensor (no interrupts)
- if ( apds.enableLightSensor(false) ) {
- Serial.println(F("Light sensor is now running"));
- } else {
- Serial.println(F("Something went wrong during light sensor init!"));
- }
-
- // Wait for initialization and calibration to finish
- delay(500);
- }
- void loop() {
-
- // Read the light levels (ambient, red, green, blue)
- if ( !apds.readAmbientLight(ambient_light) ||
- !apds.readRedLight(red_light) ||
- !apds.readGreenLight(green_light) ||
- !apds.readBlueLight(blue_light) ) {
- Serial.println("Error reading light values");
- } else {
-
- Serial.print("Ambient: ");
- Serial.print(ambient_light);
- lcd.setCursor(1, 0);
- lcd.print(red_light);
- Serial.print(" Red: ");
- Serial.print(red_light);
- lcd.setCursor(7, 0);
- lcd.print(green_light);
- Serial.print(" Green: ");
- Serial.print(green_light);
- lcd.setCursor(1, 1);
- lcd.print(blue_light);
- Serial.print(" Blue: ");
- Serial.println(blue_light);
- }
-
- // Wait 1 second before next reading
- delay(10);
- }
復制代碼
所有資料51hei提供下載:
GY-9960-3.3APDS-9960模塊RGB紅外手勢傳感 感應運動方向識別模塊.zip
(307.65 KB, 下載次數: 87)
2018-9-25 15:37 上傳
點擊文件名下載附件
資料
|