Alright, I am having extreme difficulties with this circuit. A drawing of the circuit is given below, but, in a nutshell, I can't seem to power two 5v motors without the arduino resetting.
The Arduino is powered from a 9V or USB power supply.
The motors are powered from a x4 AA battery supply.
The Arduino and motors are physically separated by an optocoupler so the arduino and motors do not share a ground either.
I have used basic diode protection and a capacitor across the motors, though this shouldn't matter because of the optocoupler.
Whenever I engage ports from the arduino via serial connection, the motors engage, the arduino resets a bunch of times and then becomes unresponsive until I restart the controller.
Other Note: The arduino is in very close proximity to the motors. Could the motors be causing voltage fluctuations in the arduino PCB due to magnetic/electrical field fluctuations from the motor?
While starting (resetting), pins 3 and 5 might be undefined.
Maybe some (strong) pull down resistors will help.
Your drawing doesn't help too much, sorry.
Your circuit is very low in contrast and hard to make out a lot of components.
In the bottom left is that a RC receiver you have hooked to the arduino?
Is the gnd of the receiver connected to the arduino gnd?
When you activate the monitor on the IDE the controller will RESET, this is normal, but the sketch should then run.
malaxtom:
Other Note: The arduino is in very close proximity to the motors. Could the motors be causing voltage fluctuations in the arduino PCB due to magnetic/electrical field fluctuations from the motor?
Undoubtedly this is the major problem. If you can't avoid proximity you will need shielding.
Hi,
What is the Rx unit that you have powered off the 3.3V from the UNO?
Have you measured the 9V as this problem occurs.
A 9V PP3 battery will not be able to do the job reliably, add 100uF cap across the battery but consider a bigger supply.
Does this happen when you are powered from the USB port.
The RC unit is the NRF24L01+. I have tried changing the power supply. I have powered it by 9V, 4 6V AA, and both 9v and USB, all to no avail. Disconnecting the motors fixes the problem completely and there are no hiccups. I have capacitors around the rail. The point here though is that the motors and arduino are NOT ON THE SAME CIRCUIT. Please excuse my yelling. They are on completely separate circuits with separate power supplies and separate grounds. The arduino controls the motors through an LED physically next to a phototransistor (inside an optocoupler package).