Analogue Light Dependent Resistor (LDR)

Analogue Light Dependent Resistor LDRThe Raspberry Pi works on digital signals - one or off.  Analogue can be any value and normally the Raspberry Pi requires an Analogue to Digital converter.

I have one connected to a 2m length of cable and one connected to a 20cm length of cable.

Requires a 1uf Capacitor

Resource - http://learn.adafruit.com/basic-resistor-sensor-reading-on-raspberry-pi

Takes a parameter of RCpin.  This is the pin where the resistor is connected to.  I have 2 connected to the system, one inside, one out.  The inside sensor is basically dark all day.

###################################################################

def RCtime(RCpin):
    reading = 0
    GPIO.setup(RCpin, GPIO.OUT)
    GPIO.output(RCpin, GPIO.LOW)
    time.sleep(0.1)

    GPIO.setup(RCpin, GPIO.IN)
    # This takes about 1 millisecond per loop cycle
    while (GPIO.input(RCpin) == GPIO.LOW):
        reading += 1
        if reading > 200:
            break
    return reading

def pdslight(GPIOPIN):
    if debug:
        print("Reading light " + str(GPIOPIN))
    x=0
    loops=5
    for y in range(0,loops):
        x = x + RCtime(GPIOPIN)
    x = x/loops
    if debug:
        print("Reading light " + str(GPIOPIN) + " " + str(x) )
    return x
##################################################################
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.49
End Date: Wednesday May-3-2017 8:22:19 PDT
Buy It Now for only: $4.49
100pc Photoresistor 10k 1M Ohm LDR Photo Resistors Light Dependent Resistor USA
100pc Photoresistor 10k 1M Ohm LDR Photo Resistors Light Dependent Resistor USA $9.95
End Date: Friday May-12-2017 20:46:19 PDT
Buy It Now for only: $9.95
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor M266
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor M266 $3.50
End Date: Friday Apr-28-2017 17:54:00 PDT
Buy It Now for only: $3.50
5pcs Photoresistor Photo LDR CDS 5mm Light Dependent Resistor Sensor GL5516
5pcs Photoresistor Photo LDR CDS 5mm Light Dependent Resistor Sensor GL5516 $2.84
End Date: Thursday May-18-2017 13:50:10 PDT
Buy It Now for only: $2.84
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 M265
20PCS Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor GL5516 M265 $3.80
End Date: Tuesday May-16-2017 22:58:12 PDT
Buy It Now for only: $3.80
20 pcs GL5549 5mm Photo Light Sensitive Resistor Photoresistor Optoresistor
20 pcs GL5549 5mm Photo Light Sensitive Resistor Photoresistor Optoresistor $5.75
End Date: Monday May-22-2017 0:04:04 PDT
Buy It Now for only: $5.75
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor
20pcs Photoresistor 5MM GL5537 LDR Photo Resistors Light Dependent Resistor $4.49
End Date: Saturday May-13-2017 4:40:38 PDT
Buy It Now for only: $4.49
PHOTO RESISTOR GL5528 LDR Light Dependent Resistors 5mm size Quantity of 10
PHOTO RESISTOR GL5528 LDR Light Dependent Resistors 5mm size Quantity of 10 $1.95
End Date: Wednesday May-10-2017 4:02:57 PDT
Buy It Now for only: $1.95
5PCS GL5516 Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor
5PCS GL5516 Photoresistor LDR CDS 5mm Light Dependent Resistor Sensor $1.95
End Date: Saturday May-20-2017 12:54:11 PDT
Buy It Now for only: $1.95
10x Photo Light Sensitive Resistor Photoresistor photocell cell 5mm GL5528 DIY
10x Photo Light Sensitive Resistor Photoresistor photocell cell 5mm GL5528 DIY $5.95
End Date: Thursday May-25-2017 4:30:36 PDT
Buy It Now for only: $5.95

« Previous12345...910

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>