![]() ![]() The color reading from the sensor could be spot on, but the reproduced color on the LED may be way off. ![]() If you are still with us and want to know more about getting the most from this guy, cool!Ī few things you should know about the sensor before we dive in too deep: I have never been able to get perfect color sampling from this guy without limiting the colors it would detect to just 6, and accurately reproducing color on an LED is not as simple as one would hope. ![]() Unless otherwise stated, this code is released under the MIT License - Please use, change and share it. ![]() Copy Code //Configure gain here //Higher numbers = less sencitive // 0x00 through 0x0f int redGain = 0x03 int greenGain = 0x0 int blueGain = 0x0f int clearGain = 0x01 //RGB LED pins //Digital PWM pins int redPin = 9 int greenPin = 10 int bluePin = 11 //Include the I2C Arduino library #include //7 bit I2C address of this sensor #define I2C_ADDRESS 0x74 #define REG_CAP_RED 0x06 #define REG_CAP_GREEN 0x07 #define REG_CAP_BLUE 0x08 #define REG_CAP_CLEAR 0x09 #define REG_INT_RED_LOĐx0A #define REG_INT_RED_HIĐx0B #define REG_INT_GREEN_LO 0x0C #define REG_INT_GREEN_HI 0x0D #define REG_INT_BLUE_LOĐx0E #define REG_INT_BLUE_HIĐx0F #define REG_INT_CLEAR_LO 0x10 #define REG_INT_CLEAR_HI 0x11 #define REG_DATA_RED_LOĐx40 #define REG_DATA_RED_HIĐx41 #define REG_DATA_GREEN_LO 0x42 #define REG_DATA_GREEN_HI 0x43 #define REG_DATA_BLUE_LO 0x44 #define REG_DATA_BLUE_HI 0x45 #define REG_DATA_CLEAR_LO 0x46 #define REG_DATA_CLEAR_HI 0x47 float redFactor = 1 float blueFactor = 1 float greenFactor = 1 //initial darkLevel int calibrationDarkness = 0 byte calibrationRed = 5 byte calibrationGreen = 5 byte calibrationBlue = 5 void setup ( void ) ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |