#include //载入总线库
#include //载入vml6040库
int x = 0;
void setup() {
Serial.begin(115200);
Wire.begin();
VEML6040.init();
Serial.println("14CORE | VEML6040 TEST CODE");
VEML6040.VEML6040_forceMode();
VEML6040.VEML6040_trigger();
delay(1000);
}
void loop() {
measureLight(); //探测颜色函数
Serial.println();
delay(500);
VEML6040.VEML6040_trigger();
}
void measureLight() { //探测颜色函数
uns16 red, blue, green, white; //定义红蓝绿白 如果是veml6070的话好像有紫外线检测
red = VEML6040.getRed(); //获取红色数值
green = VEML6040.getGreen(); //获取绿色数值
blue = VEML6040.getBlue(); //获取蓝色数值
white = VEML6040.getWhite(); //获取白色数值
Serial.println("VEML6040 DATA"); //打印文本'veml6040数据'
Serial.println();
Serial.print("Red: ");
Serial.print(red); //打印红色数值
Serial.println();
Serial.print(" Green: "); //打印绿色数值
Serial.print(green);
Serial.println();
Serial.print(" Blue: "); //打印蓝色数值
Serial.print(blue);
Serial.println();
Serial.print(" White: "); //打印白色数值
Serial.println(white);
Serial.print("RGBW Value");
Serial.println(red,green,blue,white); //打印RGBW数值
uns16 K= min(1-red,1-green,1-blue); //将RGB数值转换成CMYK色碼
uns 16 C = (1-red-K)/(1-K);
uns 16 M = (1-green-K)/(1-K);
uns 16 Y = (1-blue-K)/(1-K);
println(K,M,C,Y); //打印CMYK色碼
}
All reference designs on this site are sourced from major semiconductor manufacturers or collected online for learning and research. The copyright belongs to the semiconductor manufacturer or the original author. If you believe that the reference design of this site infringes upon your relevant rights and interests, please send us a rights notice. As a neutral platform service provider, we will take measures to delete the relevant content in accordance with relevant laws after receiving the relevant notice from the rights holder. Please send relevant notifications to email: bbs_service@eeworld.com.cn.
It is your responsibility to test the circuit yourself and determine its suitability for you. EEWorld will not be liable for direct, indirect, special, incidental, consequential or punitive damages arising from any cause or anything connected to any reference design used.
Supported by EEWorld Datasheet