image.png
I have assembled this circuit and I am trying to reproduce Pic Basic's POT instruction. The LDR value ranges from 1K to 30K ohms. The electrolytic capacitor is charged through the LDR and discharged through the 220 ohm resistor by GPIO1 (TXT) of the ESP-01. The results are satisfactory, the readings being quite stable, with values of 1 in bright light, 6 in ambient light and 35 in the dark.
But every so often, the variable t returns the actual milliseconds. Do any of you have experience with this type of montage? Can you advise me on the most suitable values for capacitor and resistor?
Code: [Local Link Removed for Guests]
t = 0
pin.mode 1, input
interrupt 1, charged
timer0 5000, discharged
wait
END
charged:
if pin(1) = 0 then return
t = millis - t
wlog t
return
discharged:
pin.mode 1, output
pin(1) = 0
pause 100
t = millis
pin.mode 1, input
return
You do not have the required permissions to view the files attached to this post.