On 21 Oct 2011 at 18:57, Yigit Turgut wrote: > LDR is light dependent resistor. When I set RB4 high to feed LDR, > current it drains will change constantly and this may cause > instability in overall operation due to overdrive of LDR. It has dark > resistance of 4 mega ohms and bright resistance of 5k ohms. Like we have been asking, what "instability" fears do you have? If you has a single LDR between +5V (or PIC output providing +5V) and groun= d=20 then max current drain is: 5V/5kOhms =3D 1mA, or power is 5V^2/5kOhms =3D 5= mW Is that too much current for your power supply? It is not too much current = for most=20 PIC I/O port lines, except perhaps RB4... as previsouly mentioned have you= =20 checked to make sure RB4 is not an "open drain" output for your particular = PIC?=20 You can not source current from an open drain output (cannot provide +VE ou= tput=20 voltage or current), you can only sink current (when turned on current, fro= m a=20 source external to the I/O pin, flows into the PIC I/O pin to GND). But anyway, you can't measure current directly with a PIC I/O line. Voltage= othe=20 other hand you can measure with a PIC ADC (or some other tricks that are sl= ightly=20 more complicated). So then you need fixed value resistor in series with you= r LDR,=20 thus giving a voltage divider: the voltage at the node of the LDR and fixed= resistor=20 will vary with varying resistance of the LDR. --=20 Brent Brown, Electronic Design Solutions 16 English Street, St Andrews, Hamilton 3200, New Zealand Ph: +64 7 849 0069 Fax: +64 7 849 0071 Cell: +64 27 433 4069 eMail: brent.brown@clear.net.nz --=20 http://www.piclist.com PIC/SX FAQ & list archive View/change your membership options at http://mailman.mit.edu/mailman/listinfo/piclist .