Hi, has this issue been solved? I am having a similar crazy trouble. So I have a switch connected via two wires to a two pin plug which is supposed to go in a two pin socket. One pin of the socket goes to 5V and the other goes to a digital I/O in the Arduino + GND (via 10K). When the switch is pressed and the digital arduino pin goes high, stuff is supposed to happen. Now here's the interesting part, if I touch the 10K arm on the other end of GND, with flesh or anything conducting, the stuff that's supposed to happen starts happening, EVEN IF THERE IS NO PLUG IN THE SOCKET (who needs a switch, switches are overrated!). Basically, the moment something conducting comes in touch with the pin connected to the digital I/O, the process starts. That's a bummer because now I can't even connect the plug in. Interestingly it doesn't happen if I touch the arm of the resistor towards the GND, only happens when I touch the arm of the resistor away from the GND, that too only when the touching medium is conducting. This setup is new but the same circuit I have used countless times without issues. What the hell is happening here?
Topic split from another topic. Please do not add your own questions to the end of other people's topics.
Could you take a few moments to Learn How To Use The Forum
It will help you get the best out of the forum in the future.
Thank you.
I suspect the answer is in this tutorial:
However, when you have read the forum guide you will know that a schematic and some code would help, and maybe some photos of your project.
Just maybe, only a rough guess, but if you had posted your code and a schematic someone could help with your problem. No drawing or code there is no easy way to offer help or a solution.
Ron
The 10k should be connected between the input pin and GND, NOT between the input pin and switch. Is it?
Yeah, that's how it is. 10K is between Input pin and GND. And when I touch the point between inout pin and GND, stuff happens. Below is the code.
int buttonpin = 12;
int motorPin = 11;
void setup() {
// put your setup code here, to run once:
pinMode(buttonpin, INPUT);
pinMode(motorPin, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if (digitalRead(buttonpin) == HIGH)
{
digitalWrite(motorPin, HIGH);
}
}
Below is the schematic
Hi,
How far is it from the Nano to the switch/socket?
Can you please post images of your project?
By the way the code you posted, in post #6, will turn the motor ON, but you have no way of turning it OFF.
Thanks.. Tom...
I can think of 4 things that might cause what you are seeing:
- The wiring is not as you think it is (check your wiring).
- The connection to the 10k resistor is not reliably made and is becoming disconnected when you touch the wire (check your soldering, screw terminals, whatever).
- The 10k resistor is not a 10k resistor, but something of much higher value (check the value).
- More seriously, there is a connection to mains somewhere and in touching the wire you are completing a circuit through your body with enough current to activate the input but not enough to feel (check your wiring, components, power supply, safety of your building electrical system).
Anyway, put the 10k pull down resistor directly between the Nano pin 12 and ground as near to the Nano as possible; not on the socket.
You have something floating, please read this:-
http://www.thebox.myzen.co.uk/Tutorial/Inputs.html
Note how it says that pull down resistors are a bad idea. Wire your switch correctly and use a 1K pull up resistor.
Alternatively you have a very electrically noisy environment and you are injecting noise into the system.
@TomGeorge the plug and socket are right next to the arduino. And yes this sketch and circuit are bare minimum as I had to reduce it to this to be sure I was experiencing hardware issue.
@PerryBebbington @Grumpy_Mike So new update, its EMI issue. I am surprised. I have two power supplies to convert home AC to DC for this system. One is giving this issue, one isn't. And Surprisingly even more, power supply is placed 1 foot from the point of trouble, even then the EMI. For now I'll just try to procure the other power supply, but how to know in the future which power supply is good and which bad?? And if I have a bad power supply, is there a way to emi proof this system?
If it is really EMI from a power supply then don't use that power supply.
Electrical interference gets in via a number of different ways, you prevent it by understanding how it gets in and dealing with the specific problem. In this case you seem to have identified a faulty power supply, so the way to fix it is to use a good power supply.
Experience, rather than anything you said in particular, makes me think there's more to this problem than a faulty power supply, but I don't know what.
Hi,
Try placing a 0.1uF capacitor between Pin12 and gnd.
Tom..
It baffles me too how can I blame the power supply. Those manufacturers of power supplies must be doing a standardized job. But its true, there is a difference in outcome from the two power supplies. But I'll keep my tests going. Also, just to note, while both the supplies are made in China, one claims in writing that it is SMPS, the other doesn't say so, and the store I bought it from has no idea whether it is SMPS or not. Can it not being SMPS have an effect?
Good Power Supply
Bad Power Supply
@TomGeorge I'll try that
If it's linear regulated it should be less noisy and shouldn't hurt.
If it's not a SMPS two things will be obvious: it will be very heavy and it will get quite warm or hot while in use.
I still think there's something else going on, my suspicion is leakage from the mains side to the low voltage side. Try this:
Disconnect any load from the power supply. Connect it to the mains. Put your multimeter on AC volts. Measure the voltage between the power supply output (either connection) and the mains safety earth connection. Do this for both supplies.
you want me to put the multimeter on AC volts and measure the voltage between the AC earth and the DC+ve?
The first one, mains earth and DC output, +ve or -ve, doesn't matter which. I'm suspicious there is significant leakage.
With nothing else connected. I'm assuming you have not connected mains earth to the output anywhere.
no no, I haven't connected the mains earth anywhere, just to the metal box all this is sitting in. But that's the same for the good power supply also.