Programme d'un Capteur de couleur

Fermé
Morgane - Modifié par Judge_DT le 17/11/2016 à 23:22
 Utilisateur anonyme - 17 nov. 2016 à 23:29
Bonjour,

J'ai ici un programme Arduino dédié à l'utilisation d'un capteur de couleur : EF 03088.

Ce capteur est composé de photodiodes (RGB) qui captent l'intensité lumineuse d'une source et renvoie une fréquence de sortie directement proportionnelle à cette intensité lumineuse reçue.

Dans le programme ci-dessous, les pins S2 et S3 caractérisent les couleurs reçues. Et les pins S0 et S1sont utilisées pour " scaling the output frequency wich can be scale into 3 pourcente values : 100%, 20% et 2%". (Je vous le met en anglais pour que vous ayez les vrais termes utilisés.)

Si quelqu'un comprend ce programme, n'hésitez pas ! Ou si vous en connaissez d'autres de programmes qui marchent.

De plus, dans nos recherches on nous parle d'un White Balance à ajuster mais il est impossible de trouver ce que c'est ! Même sur Internet on ne trouve pas ... Savez-vous ce que c'est et comment l'ajuster ?

Notre capteur change d'ailleurs tout le temps de valeurs ....

Je cherche de l'aide pour mon projet.

Merci !

Référence du capteur :
https://www.gotronic.fr/ar-capteur-de-couleur-ef03088-23534.jpg


Programme :
#define S0 4
#define S1 5
#define S2 6 // définit la sortie 2 du capteur sur le port 6 de l'arduino
#define S3 7
#define sensorOut 8

int frequency = 0; // Initialise la variable fréquence (Obligatoire)

void setup() {          // Paramètres du code
  pinMode(S0, OUTPUT); 
  pinMode(S1, OUTPUT); // On utilise le port 5 de l'arduino
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(sensorOut, INPUT); 
  
  // Setting frequency-scaling to 20%
  digitalWrite(S0,HIGH); // Tension sur la sortie 0 de 5V
  digitalWrite(S1,LOW); // OV ( LA MASSE)
  
  Serial.begin(9600); // Initialise le moniteur série à la vitesse 9600 (Qui donne les valeurs RGB)
}

void loop() {  //boucle
  // Setting red filtered photodiodes to be read
  digitalWrite(S2,LOW); //0V sortie 2
  digitalWrite(S3,LOW); //0V sortie 3
  //Lire la fréquence de sortie
  frequency = pulseIn(sensorOut, LOW); 
 //Remaping the value of the frequency to the RGB Model of 0 to 255
  frequency = map(frequency, 25,72,255,0);
  // Printing the value on the serial monitor
  Serial.print("R= ");//printing name
  Serial.print(frequency);//printing RED color frequency
  Serial.print("  ");
  delay(100); // Pause de 100 millisecondes 

  // Setting Green filtered photodiodes to be read
  digitalWrite(S2,HIGH); //Sortie 2 en 5V
  digitalWrite(S3,HIGH);
  // Reading the output frequency
  frequency = pulseIn(sensorOut, LOW);
  //Remaping the value of the frequency to the RGB Model of 0 to 255
  frequency = map(frequency, 30,90,255,0); // La fréquence idéale du vert est comprise entre ces valeurs
  // Printing the value on the serial monitor
  Serial.print("G= ");//printing name
  Serial.print(frequency);//printing RED color frequency
  Serial.print("  ");
  delay(100);

  // Setting Blue filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  // Reading the output frequency
  frequency = pulseIn(sensorOut, LOW);
  //Remaping the value of the frequency to the RGB Model of 0 to 255
  frequency = map(frequency, 25,70,255,0);
  // Printing the value on the serial monitor
  Serial.print("B= ");//printing name
  Serial.print(frequency);//printing RED color frequency
  Serial.println("  ");
  delay(100);
}

Programme :

#define S0 4
#define S1 5
#define S2 6 // définit la sortie 2 du capteur sur le port 6 de l'arduino
#define S3 7
#define sensorOut 8

int frequency = 0; // Initialise la variable fréquence (Obligatoire)

void setup() {          // Paramètres du code
  pinMode(S0, OUTPUT); 
  pinMode(S1, OUTPUT); // On utilise le port 5 de l'arduino
  pinMode(S2, OUTPUT);
  pinMode(S3, OUTPUT);
  pinMode(sensorOut, INPUT); 
  
  // Setting frequency-scaling to 20%
  digitalWrite(S0,HIGH); // Tension sur la sortie 0 de 5V
  digitalWrite(S1,LOW); // OV ( LA MASSE)
  
  Serial.begin(9600); // Initialise le moniteur série à la vitesse 9600 (Qui donne les valeurs RGB)
}

void loop() {  //boucle
  // Setting red filtered photodiodes to be read
  digitalWrite(S2,LOW); //0V sortie 2
  digitalWrite(S3,LOW); //0V sortie 3
  //Lire la fréquence de sortie
  frequency = pulseIn(sensorOut, LOW); 
 //Remaping the value of the frequency to the RGB Model of 0 to 255
  frequency = map(frequency, 25,72,255,0);
  // Printing the value on the serial monitor
  Serial.print("R= ");//printing name
  Serial.print(frequency);//printing RED color frequency
  Serial.print("  ");
  delay(100); // Pause de 100 millisecondes 

  // Setting Green filtered photodiodes to be read
  digitalWrite(S2,HIGH); //Sortie 2 en 5V
  digitalWrite(S3,HIGH);
  // Reading the output frequency
  frequency = pulseIn(sensorOut, LOW);
  //Remaping the value of the frequency to the RGB Model of 0 to 255
  frequency = map(frequency, 30,90,255,0); // La fréquence idéale du vert est comprise entre ces valeurs
  // Printing the value on the serial monitor
  Serial.print("G= ");//printing name
  Serial.print(frequency);//printing RED color frequency
  Serial.print("  ");
  delay(100);

  // Setting Blue filtered photodiodes to be read
  digitalWrite(S2,LOW);
  digitalWrite(S3,HIGH);
  // Reading the output frequency
  frequency = pulseIn(sensorOut, LOW);
  //Remaping the value of the frequency to the RGB Model of 0 to 255
  frequency = map(frequency, 25,70,255,0);
  // Printing the value on the serial monitor
  Serial.print("B= ");//printing name
  Serial.print(frequency);//printing RED color frequency
  Serial.println("  ");
  delay(100);
}
A voir également:

1 réponse

Utilisateur anonyme
17 nov. 2016 à 23:29
Bonsoir

pour la balance des blancs
https://fr.wikipedia.org/wiki/Balance_des_blancs

Et sinon, je ne connais pas bien le C, mais pour ceux qui savent et qui pourraient vous aider, y'a t il une question?
0