I’m using the circuit in the attached image to implement a finger switch, meaning a switch that is made from two metal contacts and the switch is closed when you place your finger across the contacts. In the circuit,
R1 = 470 ohm,
R2 = 5 kohm,
Q1 = Q2 = KSP2222A NPN transistors,
+5 V and Gnd are the Arduino 5V and ground connections.
When using the computer USB as a power supply, this setup works perfectly using essentially the code in the Arduino AnalogInOutSerial example. I get a very stable value of 1023 on A0 when no connection is being made, and a fairly stable 150-160 value when a connection is being made. In order to make it a switch, I set a threshold value of 350 with A0 > 350 being open and closed otherwise. To test, I’m just toggling the built-in LED.
My problem is that when I disconnect the USB power and connect a 5V external PSU I find that the switch closes if I touch just the finger switch contact that is connected to R2. That is, I don’t have to close the switch at all, I just touch that one contact and this is enough for the value at A0 to cross the threshold.
I’m finding this hard to debug because if I plug the USB power back in, the circuit behaves properly again, so I can’t see the values that are coming in at A0 on the Serial monitor.
Has anyone any suggestions as to why the behavior changes with external power? How can I fix this?