m (Djbrown a déplacé la page Item:Color Sensor TCS 3200 vers Item:Capteur de Couleur TCS 3200) |
|||
(2 révisions intermédiaires par le même utilisateur non affichées) | |||
Ligne 15 : | Ligne 15 : | ||
=Câblage : = | =Câblage : = | ||
+ | {{#annotatedImageLight:Fichier:Item-Color Sensor TCS 3200.png|0=842px|hash=|jsondata=|mediaClass=Image|type=frameless|alt=Item-Color Sensor TCS 3200|align=center|src=https://www.wikidebrouillard.org/images/2/26/Item-Color_Sensor_TCS_3200.png|href=./Fichier:Item-Color Sensor TCS 3200.png|resource=./Fichier:Item-Color Sensor TCS 3200.png|caption=|size=842px}} | ||
Ligne 27 : | Ligne 28 : | ||
| valign="middle" align="left" |Aucune Librairies | | valign="middle" align="left" |Aucune Librairies | ||
|- | |- | ||
− | | valign="middle" bgcolor="#999999" align="center" | | + | | valign="middle" bgcolor="#999999" align="center" |Définition des pins et des variables |
− | | valign="middle" align="left" | | + | | valign="middle" align="left" |#define S0 4 |
+ | |||
+ | <nowiki>#</nowiki>define S1 5 | ||
+ | |||
+ | <nowiki>#</nowiki>define S2 6 | ||
+ | |||
+ | <nowiki>#</nowiki>define S3 7 | ||
+ | |||
+ | <nowiki>#</nowiki>define sensorOut 8 | ||
+ | |||
+ | int redFrequency = 0; | ||
+ | |||
+ | int greenFrequency = 0; | ||
+ | |||
+ | int blueFrequency = 0; | ||
+ | <br /> | ||
|- | |- | ||
| valign="middle" height="17" bgcolor="#999999" align="center" |Dans le Setup | | valign="middle" height="17" bgcolor="#999999" align="center" |Dans le Setup | ||
− | | valign="middle" bgcolor="#999999" align="center" | | + | | valign="middle" bgcolor="#999999" align="center" |Configuration des pins & initialisation des valeurs |
− | | valign="middle" align="left" | | + | | valign="middle" align="left" |pinMode(S0, OUTPUT); |
+ | |||
+ | pinMode(S1, OUTPUT); | ||
+ | |||
+ | pinMode(S2, OUTPUT); | ||
+ | |||
+ | pinMode(S3, OUTPUT); | ||
+ | |||
+ | pinMode(sensorOut, INPUT); | ||
+ | |||
+ | digitalWrite(S0,HIGH); | ||
+ | |||
+ | digitalWrite(S1,LOW); | ||
|- | |- | ||
| valign="middle" height="41" bgcolor="#999999" align="center" |Dans le Loop | | valign="middle" height="41" bgcolor="#999999" align="center" |Dans le Loop | ||
| valign="middle" bgcolor="#999999" align="center" |Utilisation | | valign="middle" bgcolor="#999999" align="center" |Utilisation | ||
− | | valign="middle" align="left" | | + | | valign="middle" align="left" |redFrequency = pulseIn(sensorOut, LOW); |
+ | |||
+ | greenFrequency = pulseIn(sensorOut, LOW); | ||
+ | |||
+ | blueFrequency = pulseIn(sensorOut, LOW); | ||
|} | |} | ||
Ligne 45 : | Ligne 77 : | ||
=Exemple : = | =Exemple : = | ||
<syntaxhighlight lang="arduino"> | <syntaxhighlight lang="arduino"> | ||
− | + | #define S0 4 | |
+ | #define S1 5 | ||
+ | #define S2 6 | ||
+ | #define S3 7 | ||
+ | #define sensorOut 8 | ||
+ | |||
+ | int redFrequency = 0; | ||
+ | int greenFrequency = 0; | ||
+ | int blueFrequency = 0; | ||
+ | |||
+ | void setup() { | ||
+ | pinMode(S0, OUTPUT); | ||
+ | pinMode(S1, OUTPUT); | ||
+ | pinMode(S2, OUTPUT); | ||
+ | pinMode(S3, OUTPUT); | ||
+ | |||
+ | pinMode(sensorOut, INPUT); | ||
+ | |||
+ | digitalWrite(S0,HIGH); | ||
+ | digitalWrite(S1,LOW); | ||
+ | |||
+ | Serial.begin(9600); | ||
+ | } | ||
+ | void loop() { | ||
+ | digitalWrite(S2,LOW); | ||
+ | digitalWrite(S3,LOW); | ||
+ | |||
+ | redFrequency = pulseIn(sensorOut, LOW); | ||
+ | |||
+ | Serial.print("R = "); | ||
+ | Serial.print(redFrequency); | ||
+ | delay(100); | ||
+ | |||
+ | digitalWrite(S2,HIGH); | ||
+ | digitalWrite(S3,HIGH); | ||
+ | |||
+ | greenFrequency = pulseIn(sensorOut, LOW); | ||
+ | |||
+ | Serial.print(" V = "); | ||
+ | Serial.print(greenFrequency); | ||
+ | delay(100); | ||
+ | |||
+ | digitalWrite(S2,LOW); | ||
+ | digitalWrite(S3,HIGH); | ||
+ | |||
+ | blueFrequency = pulseIn(sensorOut, LOW); | ||
+ | |||
+ | Serial.print(" B = "); | ||
+ | Serial.println(blueFrequency); | ||
+ | delay(100); | ||
+ | } | ||
</syntaxhighlight><br /> | </syntaxhighlight><br /> | ||
}} | }} |
Pour utiliser le capteur de couleur il n'y a besoin d'aucunes bibliothèques
TCS 3200 | ||
Avant le Setup | Importation de la bibliothèque | Aucune Librairies |
Définition des pins et des variables | #define S0 4
#define S1 5 #define S2 6 #define S3 7 #define sensorOut 8 int redFrequency = 0; int greenFrequency = 0; int blueFrequency = 0;
| |
Dans le Setup | Configuration des pins & initialisation des valeurs | pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT); pinMode(S2, OUTPUT); pinMode(S3, OUTPUT); pinMode(sensorOut, INPUT); digitalWrite(S0,HIGH); digitalWrite(S1,LOW); |
Dans le Loop | Utilisation | redFrequency = pulseIn(sensorOut, LOW);
greenFrequency = pulseIn(sensorOut, LOW); blueFrequency = pulseIn(sensorOut, LOW); |
Aucune autres fonctionalités
#define S0 4
#define S1 5
#define S2 6
#define S3 7
#define sensorOut 8
int redFrequency = 0;
int greenFrequency = 0;
int blueFrequency = 0;
void setup() {
pinMode(S0, OUTPUT);
pinMode(S1, OUTPUT);
pinMode(S2, OUTPUT);
pinMode(S3, OUTPUT);
pinMode(sensorOut, INPUT);
digitalWrite(S0,HIGH);
digitalWrite(S1,LOW);
Serial.begin(9600);
}
void loop() {
digitalWrite(S2,LOW);
digitalWrite(S3,LOW);
redFrequency = pulseIn(sensorOut, LOW);
Serial.print("R = ");
Serial.print(redFrequency);
delay(100);
digitalWrite(S2,HIGH);
digitalWrite(S3,HIGH);
greenFrequency = pulseIn(sensorOut, LOW);
Serial.print(" V = ");
Serial.print(greenFrequency);
delay(100);
digitalWrite(S2,LOW);
digitalWrite(S3,HIGH);
blueFrequency = pulseIn(sensorOut, LOW);
Serial.print(" B = ");
Serial.println(blueFrequency);
delay(100);
}
Item-TCS_3200_TCS3200.jpg Published
Vous avez entré un nom de page invalide, avec un ou plusieurs caractères suivants :
< > @ ~ : * € £ ` + = / \ | [ ] { } ; ? #