Summary
The resistances for the leds are 150 homs and 10 khoms for the detector.
The code :
/
* Capteur de couleur à l'aide de led bleu, vert et rouge et de photodiode
* par Desperado
/
#define bleu A0
#define vert A1
#define rouge A2
int capteur_bleu;
int capteur_vert;
int capteur_rouge;
int maxi = 0;
int mini = 0;
void setup() {
pinMode(bleu, INPUT);
pinMode(vert, INPUT);
pinMode(rouge, INPUT);
Serial.begin(9600);
}
void loop() {
capteur_bleu = analogRead(bleu);
capteur_vert = analogRead(vert);
capteur_rouge = analogRead(rouge);
Serial.print("bleu : "); Serial.println(capteur_bleu);
Serial.print("rouge : "); Serial.println(capteur_rouge);
Serial.print("vert : "); Serial.println(capteur_vert);
Serial.println(" ");
//Dectection du blanc
if (capteur_bleu <= 300 && capteur_rouge <= 80 && capteur_vert >= 55) {
Serial.println("BLANC");
}
//detection du bleu
else if (capteur_bleu <= 350 && capteur_rouge >= 135 && capteur_vert <= 100) {
Serial.println("BLEU");
}
//detection du vert
else if (capteur_bleu >= 380 && capteur_rouge <= 140 && capteur_vert >= 90) {
Serial.println("VERT");
}
//detection du rouge
else if (capteur_bleu >= 380 && capteur_rouge <= 80 && capteur_vert <= 85) {
Serial.println("ROUGE");
}
//detection du noir
else if (capteur_bleu >= 460 && capteur_rouge >= 170 && capteur_vert >= 130) {
Serial.println("NOIR");
}
//couleur inconu
else {
Serial.println("COULEUR INCONU");
}
Serial.println(" ");
delay(1000);
}
Print Settings
Printer Brand:
Up
Printer:
Up Mini
Rafts:
Yes
Supports:
No
Resolution:
0.2
Tags
Model Source
