The ColorPal is capable of taking standard RGB readings, but it must be calibrated to compensate for its surroundings. To do this, black and white references were collected and factored into future colorimetric readings. We used the "Serial.print" and the "Serial.read" command to guide the user through the calibration process.
Serial.println("Begin by calibrating. Press 'b' to take black reference, 'w' to take white reference. Then press 'r' to take a reading.");
}
boolean blackDone = false;
boolean whiteDone = false;
void loop()
{
readcolor();
int inputChar;
int redMeasure = red;
int blueMeasure = blu;
int greenMeasure = grn;
int redBRef;
int blueBRef;
int greenBRef;
int redWRef;
int blueWRef;
int greenWRef;
inputChar = Serial.read();
if (inputChar == 'b'){
readcolor();
redBRef = red;
blueBRef = blu;
greenBRef = grn;
blackDone = true;
Serial.println("OK!");}
if (inputChar == 'w'){
readcolor();
redWRef = red;
blueWRef = blu;
greenWRef = grn;
whiteDone = true;
Serial.println("OK!");}
if (inputChar == 'r'){
if (blackDone == false){
Serial.println("Take black reference");
}
if (whiteDone == false){
Serial.println("Take white reference");
}
if (blackDone == true && whiteDone == true){
Serial.print("R");
Serial.print(red);
Serial.print(" G");
Serial.print(grn);
Serial.print(" B");
Serial.println(blu);
gotcolor = 0;
delay(100);
}
}
}
...to be continued
No comments:
Post a Comment