I've posted several posts before concerning color sensors but as of the moment, we're totally lost on what to do with the color sensor experiments.
So this is our objective -- to get a range of values as threshold for the color sensor, which acts as our ambient light sensor. Initially, we planned for it to measure the brightness of the room and when we determine the threshold range, we would program it to produce light through the led. The catch is that the light produced in the led is dependent on how bright the color senses the room is. So, for example, it's around 2 in the afternoon and the room (let's say, the bedroom) is still bright enough due to the sun coming in from the window, the color sensor detects the ambient surruondings and then tells the led to light like about 20% of the maximum brightness.
But to make things less complicated, our adviser told us why not measure the "darkness" of the room. She told us maybe instead of measuring the brightness, we measure just how dark the room already is and then program it to tell the led to turn on a certain brightness. So, she suggested why not get the rgb values of shades of gray to black and use it as threshold range. And when we use it in a room, and the room's darkness enters that threshold range, the output light must emit the same lux as the standard lux assigned for the bedroom.
Now, the idea was absolutely promising but we got confused when we found it that color sensor rgb values are frequencies, while rgb values on a color chart are simply rgb values. So, we weren't exactly sure if it's "applicable"?
Now we're at loss of what to do, and what experiment to do and how to do it. If y'all have any ideas, it would be very much appreciated if you could share.
Thank you.
Also we use this code:
/* Arduino Color Sensing Tutorial
*
* by Dejan Nedelkovski, www.HowToMechatronics.com
*
*/
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut 8
//int frequency = 0;
int fRed = 0;
int fBlue = 0;
int fGreen = 0;
void setup() {
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
// Setting frequency-scaling to 20%
digitalWrite(S0,HIGH);
digitalWrite(S1,LOW);
Serial.begin(9600);
}
void loop() {
// Setting red filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
// Reading the output frequency
fRed = pulseIn(sensorOut, LOW);
// Printing the value on the serial monitor
Serial.print("R= ");//printing name
Serial.print(fRed);//printing RED color frequency
Serial.print(" ");
delay(250);
// Setting Green filtered photodiodes to be read
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
// Reading the output frequency
fGreen = pulseIn(sensorOut, LOW);
// Printing the value on the serial monitor
Serial.print("G= ");//printing name
Serial.print(fGreen);//printing RED color frequency
Serial.print(" ");
delay(250);
// Setting Blue filtered photodiodes to be read
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
// Reading the outpt frequency
fBlue = pulseIn(sensorOut, LOW);
// Printing the value on the serial monitor
Serial.print("B= ");//printing name
Serial.print(fBlue);//printing RED color frequency
Serial.println(" ");
delay(250);
}