Servo fights with my pot-controlled DC motor

I have a filament winder project that uses a DC motor whose speed is controlled by dialing a potentiometer. There is also a servo which moves a guide back and forth across the spool as the filament winds on. When you press and hold a button, you can use the potentiometer to position the servo to set it's min and max positions. I had this working with a breadboard and an Uno, and am now trying to set it up with a custom board. I basically did a PCB version of the breadboard Arduino, using a 328 that came with an Uno bootloader and ran traces around to the various connections I need.

In this version, the potentiometer does nothing while the servo jerks around all over the place. When I hold the button, the potentiometer positions the servo just fine. The motor does not run until I turn the potentiometer up to it's full extent, at which point the motor turns on full and the servo stops freaking out. Unless it is turned all the way up, it basically acts as if the pot is unplugged altogether.

If I disable the servo by commenting out its assignment

//  servo.attach(guidePin);

then pot controls the speed of the motor the way it should. I originally tried removing any code that commands the servo, but it didn't work. If there is a servo object assigned to the pin and nothing after that, it will misbehave. The pin assigments are correct, the servo and motor are both on PWM pins and the motor is run through MOSFET and diode. Any ideas on where to look for the problem?

In this version

?

What I mean is in this version of the winder using a custom PCB, versus when I had it set up using a breadboard with an Uno. It worked on the breadboard with the same code (aside from different pin assignments), but it's not working on the new PCB.

And that's all we've got to go on?

Good luck.

Attached is schematic, pcb layout, Fritzing file, code.

Since taking the servo in and out of the code fixes the problem, I'm wondering if the problem would be code, or hardware. What kind of hardware problem might cause the servo to interfere with everything else? Why does it persist when the servo is attached but not doing anything? Is there something in the servo library that continues to interact with the servo through its pin even when it is never written to? If the servo's pin got shorted to the pin next to it, could it interfere with other parts of the circuit that aren't attached to it?

Winduino.fzz (60.1 KB)

Winduino.ino (8.7 KB)

What kind of hardware problem might cause the servo to interfere with everything else?

Poor / badly decoupled power supply.

If you only want one of these things for your own use why not go back to the breadboard version that works. No more time wasted, no more money spent!

...R

I'm wondering if the problem would be code, or hardware

More than likely the problem is due to something you changed, intentionally or unintentionally.