how to detect current using PIC16F877A

the circuit having parallel lamps. if one of the lamp is break down, the value of current will smaller than usual. the output of microcontroller will give warning when the current is smaller than usual. how to detect the decrease of current using PIC 16f877A? please help me.

You first need to create a signal proportional to the total lamp current - such as via a series "shunt" resistor. If the shunt is 1Ω and the current is (say) 0.1A then you would have a 0.1V signal.

Then you could use an external comparator circuit to detect the "shunt" voltage drop to the value corresponding to the one lamp only state. The comparator output could then be used as input to one of the PIC's digital input lines. Code reads the digital input line to detect the change.

Alternatively, you could feed the same shunt voltage as an input to the PIC's A-to-D converter module. After reading in the voltage, use your code to determine the current level and hence deduce the lamp states.

This is a relatively simple task to be committing to the substantial power of the PIC - much like breaking peanuts with a hammer. Presumably this is more about gaining experience with PIC's.

You can use a 0.5R resistor in series with each lamp and measure the voltage drop across that resistor.

If the voltage drop equals zero then the lamp is burned.

Another option is to use one resistor and measure the total current of the lamps but this may give you false results due to variations on the applied voltage across the lamps (if the lamps draw a small amount of current). However, if the lamps draw above 0.5 Amps then you can do it with one resistor safely.