Ligne 271 : |
Ligne 271 : |
| Connectez une LED à la pin 11 par l'intermédiaire d'une résistance. | | Connectez une LED à la pin 11 par l'intermédiaire d'une résistance. |
| Pour plus d'information: | | Pour plus d'information: |
− | * voir | + | * voir http://mchobby.be/wiki/index.php?title=Photo-résistance (en FRANCAIS) |
− | For more information see www.ladyada.net/learn/sensors/cds.html */
| + | * voir htt://www.ladyada.net/learn/sensors/cds.html (en anglais) |
| + | */ |
| | | |
− | int photocellPin = 0; // the cell and 10K pulldown are connected to a0 | + | int photocellPin = 0; // La photo-résistaance raccordée sur la PIN A0 (avec une résistance Pull-Down de 10K Ohms) |
− | int photocellReading; // the analog reading from the sensor divider | + | int photocellReading; // Contient la lecture de sur senseur (pont diviseur Photo-résistance + Résistance) |
− | int LEDpin = 11; // connect Red LED to pin 11 (PWM pin) | + | int LEDpin = 11; // LED rouge connectée sur la pin 11 (sortie PWM) |
| int LEDbrightness; // | | int LEDbrightness; // |
| void setup(void) { | | void setup(void) { |
− | // We'll send debugging information via the Serial monitor | + | // Configuration du port série pour envoyer des message de débugging |
| Serial.begin(9600); | | Serial.begin(9600); |
| } | | } |
Ligne 286 : |
Ligne 287 : |
| photocellReading = analogRead(photocellPin); | | photocellReading = analogRead(photocellPin); |
| | | |
− | Serial.print("Analog reading = "); | + | Serial.print("Lecture Analogique = "); |
− | Serial.println(photocellReading); // the raw analog reading | + | Serial.println(photocellReading); // La valeur analogique brute |
| | | |
− | // LED gets brighter the darker it is at the sensor | + | // Plus le senseur est dans l'ombre et plus la LED est brillante. |
− | // that means we have to -invert- the reading from 0-1023 back to 1023-0 | + | // Cela signifie que nous devons INVERSER la lecture de 0-1023 vers 1023-0 |
| photocellReading = 1023 - photocellReading; | | photocellReading = 1023 - photocellReading; |
− | //now we have to map 0-1023 to 0-255 since thats the range analogWrite uses | + | // Maintenant, nous transformons les valeurs de 0-1023 vers 0-255 (puisque une sortie PWM/analogique utilise cette plage de valeurs) |
| LEDbrightness = map(photocellReading, 0, 1023, 0, 255); | | LEDbrightness = map(photocellReading, 0, 1023, 0, 255); |
| analogWrite(LEDpin, LEDbrightness); | | analogWrite(LEDpin, LEDbrightness); |
Ligne 301 : |
Ligne 302 : |
| [[fichier:cds-example3.jpg]] | | [[fichier:cds-example3.jpg]] |
| | | |
− | You may want to try different pulldown resistors depending on the light level range you want to detect!
| + | Vous pourriez avoir besoin d'essayer différentes résistance Pull-Down an fonction du niveau de luminosité ambiant que vous voulez détecter. |
| | | |
| == Simple code for analog light measurements == | | == Simple code for analog light measurements == |