LDR: Difference between revisions
Jump to navigation
Jump to search
Line 2: | Line 2: | ||
An LDR is a light-dependent resistor. It changes it's resistance depending on the light falling onto the LDR. | An LDR is a light-dependent resistor. It changes it's resistance depending on the light falling onto the LDR. | ||
[[File:Ldr01.PNG]] | [[File:Ldr01.PNG|200px]] | ||
= How to connect it electrically = | = How to connect it electrically = |
Revision as of 00:26, 30 August 2020
Description
An LDR is a light-dependent resistor. It changes it's resistance depending on the light falling onto the LDR.
How to connect it electrically
Connecting the light dependent resistor (LDR). The value you read is dependent on how bright it is.
How to control it in MicroPython
This makes Pin 34 an analog input and set it to 12 bit. It reads the analog value every second and print it to the console.
#Example usage for ESP32
from machine import Pin, ADC
from time import sleep
analogPin = ADC(Pin(34))
analogPin.atten(ADC.ATTN_11DB)
while True:
analogVal = analogPin.read()
print(analogVal)
sleep(1)
Related Tutorial Videos