Problem with earth connection

Hey !
I’m trying to make an automatic chess game. It’s basically a chess board with a REED matrix beneath it (to record the players moves) and a system composed of rails, shafts, pulleys and stepper motors to move an electromagnet (used to move the pieces). Everything is planed (knights moves, magnetic part handled to…) and this paragraph was only written to give you guys a bit of background information, please don’t worry about how the project works precisely.
Now here is my problem that appeared twice during my project :

  1. The first time is when I tried to hook up a few LEDs to test my PCB, please find herewith the precise schematics. The power supply supplies 5V (from an Arduino UNO). I’m using a 2N7000G (source is the left pin, gate the middle one and drain the right one). Now, a mosfet should “connect” the drain to the source when getting HIGH on the gate. So when I disconnect the orange wire from the 5V, the LED should turn off. It does… when my hand is not close/touching the wire ! Indeed, when the orange (gate pin) wire is not connected to 5V and I (or anybody else) touches or even approaches the wire, the LED turns on with its brightness proportional to how close I am from the wire. However, I can avoid this from happening by connecting a other wire to GND and touching it with my hand.

  2. The second case is when trying to have a Nema 17 (12V, 30 Ohms, 0.4A) work with a A4988. Please find herewith the precise schematics.
    The power supply supplies 12V. I already calibrated the controller for my motor with the pot. I uploaded this program on my Arduino UNO (void loop only):
    “digitalWrite(dirPin, LOW);
    digitalWrite(stepPin,HIGH);
    delayMicroseconds(500);
    digitalWrite(stepPin,LOW);
    delayMicroseconds(500); “.
    Now, clockwise, the motor turns more or less correctly but counterclockwise, it does not turn at all. And a phenomena quite similar to the fisrt case appear: when I approach my hand from the motor (or even the cables of it), it seriously has trouble to turn and if I touch the motor, it completely stops. But the same solution that worked in the first case appears here, if I plug a wire to GND and touch it, everything works perfectly…

I have no idea what’s the problem (maybe an earth connection problem).
Could any one give me a answer to my problem. What is the problem with my circuit/component ? Should I ground my circuit ? If yes, how ?
I’m a newbie in electronics so maybe my question have no sense… :slight_smile:
Sorry for writing a book about my problem. :confused:
Thank you !

You wrote this: " when I approach my hand from the motor (or even the cables of it), it seriously has trouble to turn and if I touch the motor, it completely stops.".

Which is the classic symptom of a FLOATING pin on your arduino.

I am not going to study your code, you know it better than anyone. So, verify all the pins you use in your program are either at 5 volts or at 0 volts. Somewhere that is not the case. Could be a loose connection or a broken wire.

Paul

Hey !
Thank you so much Paul ! That was indeed the problem.
Have a nice day