Hey guys i was wondering Is it possible to turn ground pin off or make it somehow turn off in the code in a different tricky way?
No, that is not possible.
Why would you want to do that ? Removing the ground could cause damage to the Arduino by currents taking another route.
Okay misunderstanding. What I am trying to do is this. I have pins 4 and 5 connected to a motor. the motor runs in different directions depending on direction of current. Therefore I am trying to connect ground pin4 of arduino to the ground of the motor and serial pin4 of arduino to the 5v on the motor. And the exact same thing but in reverse for the pin5. As the serial pins can be turned on or off I can have no current flowing through the circuit but the issue is that there will be ground connected to the ground and the 5v of the motor which won't work at all. So I want to switch between ground on pin4 and pin5 at the same time as switching between serial pin4 and serial pin 5 therefore reversing polarity" -- I do not want to use a relay setup for this so any suggestions will be awesome.
ground pin4 of arduino
serial pin4 of arduino
Not sure what you mean there....
You can not use an Arduino pin to power a motor. You can use it for a led of 20mA.
To make a motor go in both directions, you need an H-bridge.
You can buy a module or a chip for an H-bridge, or you can make a H-bridge with transistors or mosfets.
What kind of motor is it ? How many Volts ? Which Arduino board are you using ? How do you power the motor ?
So H brdige could work?
Yes, there is not other way to make a motor run in both directions. When you would use relays, you are actually making an H-bridge with relays
Another thing i wanted to know i have this diagram of a h bridge setup. Is it possible to remove the switch and run the motors direction with code instead of pushing the switch.
Sure, that switch is only used for demonstration.
However, the L293D can be used for small 12V motors. It can be used maybe for 6V motors (but they would have almost no power) but not for 3V motors. And only for small motors, small, as in: not big.
Then you should turn off Arduino instead of ground pin.