arduino - Using Photoresistor And analogRead() Value -


i have photoresistor connected , reading values between 0-1023 fine. but, what measure of? proportional resistance or current or voltage? have reading 1020 ambient light (which is, me, dark-ish). when hit red laser drops around 210.

hardware details: not have data sheet on photoresistor - pulled out of busted night light. resistor in circuit 220 ohm.

schematic: r = 220 ohm, pr = photoresitor

5v--r--a0pin        --pr--gnd   

i using simplot , code:

int lightpin = 0; int buffer[20];  void setup() {  serial.begin(19200); }  void loop() {  int data1;  int light = analogread(lightpin);  data1 = light;  plot(data1); }  void plot(int data1) {   int pktsize;    buffer[0] = 0xcdab;             //simplot packet header. indicates start of data packet   buffer[1] = 1*sizeof(int);      //size of data in bytes. not include header , size fields   buffer[2] = data1;    pktsize = 2 + 2 + (1*sizeof(int)); //header bytes + size field bytes + data    //important: change serial port connected pc   serial.write((uint8_t * )buffer, pktsize); } 

you reading voltage (analogread(lightpin)). can convert adc reading voltage process:

percent = (adcnumber / maxadc) voltage = percent * maxvoltage 

so you

 voltage = (data1/ 1023.0)* 5.0 

you reading voltage, voltage changing, because "resistance" of photoresistor changing.

if using voltage divider equation

vout = r1/(r1+r2) * vin 

but can't give equation calculate resistance or current without more information on circuit.


Comments

Popular posts from this blog

python - How to create a legend for 3D bar in matplotlib? -

java - Multi-Label Document Classification -

php - Dynamic url re-writing using htaccess -