Modifications

Sauter à la navigation Sauter à la recherche
1 018 octets ajoutés ,  6 mai 2012 à 22:03
Ligne 188 : Ligne 188 :  
| align="left" | 4.5 V
 
| align="left" | 4.5 V
 
|}
 
|}
 +
''This table indicates the approximate analog voltage based on the sensor light/resistance w/a 5V supply and 1K pulldown resistor''
 +
 +
Note that our method does not provide linear voltage with respect to brightness! Also, each sensor will be different. As the light level increases, the analog voltage goes up even though the resistance goes down:
 +
 +
Vo = Vcc ( R / (R + Photocell) )
 +
 +
That is, the voltage is proportional to the inverse of the photocell resistance which is, in turn, inversely proportional to light levels.
 +
 +
== Simple demonstration of use ==
 +
 +
[[Fichier:cds-example1.jpg]]
 +
 +
[[Fichier:cds-example2.jpg]]
 +
 +
This sketch will take the analog voltage reading and use that to determine how bright the red LED is. The darker it is, the brighter the LED will be! Remember that the LED has to be connected to a PWM pin for this to work, I use pin 11 in this example.
 +
 +
These examples assume you know some basic Arduino programming. If you don't, maybe spend some time reviewing the basics at the Arduino tutorial?
    
Source:  [http://www.ladyada.net/learn/sensors/cds.html cds]
 
Source:  [http://www.ladyada.net/learn/sensors/cds.html cds]
29 918

modifications

Menu de navigation