I need to connect 8 panic switches to PIC 8 inputs & make an alarm when one or more is activated.Also I'm showing the corresponding zone on a single seven segment display.
My only doubt is that the inputs are coming from long distance like 30 meters,50 meters max.
There really not anything needed your reading a button and 5 volts is not going to have a great drop even at 50 meters but I would use a 10 k pullup. At 150 feet a 22 AWG has 2.421 ohms resistance
Here's how I would do it: R1 pulls up the port pin when the switch is opened. R2-C1 acts as a low-pass filter to shunt RFI (from Cell phones, etc) and static electricity to ground and provides some switch de-bounce. R3 limits the current that a static discharge and RFI can inject into the ground plane under the PIC. If static electricity (charged humans touching the switch resets the PIC), you may have to take more drastic measures.
If you use a 74hc147 (or similar part) you will turn 1 or 9 switches into binary. Then use a 7 segment decoder to drive the LEDs. Sorry no PIC but two simple ICs.
Here's how I would do it: R1 pulls up the port pin when the switch is opened. R2-C1 acts as a low-pass filter to shunt RFI (from Cell phones, etc) and static electricity to ground and provides some switch de-bounce. R3 limits the current that a static discharge and RFI can inject into the ground plane under the PIC. If static electricity (charged humans touching the switch resets the PIC), you may have to take more drastic measures.
If you read the switch several times with a delay inbewteen, then if you get the same result every time you know the read is valid and not noise fron a cell phone etc.
S imple software filter.
Guys I made my hardware like this.I got to know sometimes the PIC detects like open circuit even the switch still closes...!
Does it due to series 4.7K resister?