Servo motors lose PWM signal, arduino fio stops writing it

Hello world!
I have a robot driven by two dc motors, and a robotic arm powered by 2 servos. Everything was working beautifully and the robot was driving around and doing what it was supposed to be doing. Next, i decided to install an N-channel MOSFET to kill the power to my drive motors and servos so that the battery power is not wasted when the robot is idling and not doing anything. This is where I ran into this issue:
Servos and dc motors are connected to the same + and - voltage rails. This negative voltage rail goes trough a transistor to the common ground. Transistor is always turned on, and I also have 100k resistor pulling gate to ground in case i want to turn my MOSFET off. After driving for a while and moving servos, my Arduino Fio stops writing PWM signal to the servos, i checked this with oscilloscope. Im using standard Servo.h library. Im not using Servo.detach() or pinMode( foo, INPUT) or anything else (to the best of my knowledge) that would turn off a pullup resistor (and i dont know actually if its getting turned off). Once the servos stop working, they wont turn on unless the board is reset. I have no idea what is causing this
-Im pretty sure that my circuit (made on a prototype board) is alright. I remade the circuit from scratch and all connections seem good.
-I soldered small capacitors across dc motor leads for noise suppression and also have a large capacitor filtering noise near servos and dc motors. There is still some noise when my robot drives, so my power supply is not perfect. Im using a 3.3v 1000mAh lipo (with 3.7 nominal voltage) as a power source.
-when servos loose pwm signal, my DC motors are still running, my digital servo has power (but no signal), and my analog servo feels very weak (feels like it has no power). They are all connected to the same + - voltage rails
-I tried swapping out servo motors, even tried servos of different kind: same issue
-i unplugged the servos. Servo pwm pins still lose signal. Pwm pins that drive motors (via separate motor driver) are still active
Anyone has any idea whats happening here?
Is there something in Servo.h library thats causing this glitch? What do you guys think?

Thank you very much!

It's not clear from your description whether the problem arises even if the Mosfet power switch is ON all the time or if it only happens when it is cycled OFF and ON. If so does it happen after every cycle or only some of the time.

Have you tried putting a jumper wire to bypass the Mosfet and get back (temporarily) to the circuit you had before the Mosfet was added. Please NOTE that I have no idea if that sort of jumper would harm the Mosfet.


Hello Robin!
Thank you for your reply!

In my code, I turn the transistors on and keep them on entire time. I tried bypassing MOSFET transistors and the problem is still there.
My servos could be loosing power at some point because my DC motors may be pulling all battery current. At that point, i think that somehow the pwm pin in a code is disassociated with my servo object.
I looked inside the Servo.h library and I dont completely understand stuff about timers and interrupt handling, and I think that this is what screwing me over. Ardunio fio is a new board on the market, and Servo.h library has been last updated in like.... 2009?
Any thoughts on this?

I plan on trying to write my own little library to move the servo by sending a pulse like



In my code, I turn the transistors on and keep them on entire time. I tried bypassing MOSFET transistors and the problem is still there.
My servos could be loosing power at some point because my DC motors may be pulling all battery current. At that point, i think that somehow the pwm pin in a code is disassociated with my servo object.

In your first post you said everything was working beautifully before you added the Mosfet. That's why I thought bypassing it would get you back to the earlier situation.

There must be some other change(s).

It is a common problem here for people to try to draw too much power causing the Arduino to reset - but if that did not happen before you added the Mosfet ????

I guess it's possible the pre-Mosfet version was very nearly causing a problem and the Mosfet has tipped it over the edge.


im actually starting to panic now.

I now have two robots, one with MOSFETS installed and the other one without. Both have the same issue with the code that used to work well. I dont think that mosfet is a part of the problem anymore.

Arduino is not getting reset , its connected to the battery in parallel so its pulling whatever current it needs (battery is 3.3v lipo, 1000mah, 2C discharge.) Now here is a new observation. I connected a potentiometer reference leads to the same ± rails where my motors are connected. Im reading pot value with an analog pin. When the robot drives around, i can read the pot value just fine (current consumed is about 0.5A) . HOWEVER, if start messing with the motors, like hold them to stall them, I noticed that I can no longer read the pot value with my analog pin… When i reset the board, everything is back to normal.
So for some reasons, my pins stop working in a middle of the program. I have like 3 arduino fio’s, and i tried swapping the boards and i observe exactly the same thing, so I know that its not a defect in an individual board. Any ideas?

Many many postings here about motors or servos are due to powering these from the
same supply as the Arduino.

Don't do this - not unless you really know what you're doing and have an oscilloscope...

Also if you post your circuit and your code we might see what the problem is, since
you have only told us the symptoms but we don't get to see the patient!

Mark T,
Thanks for a reply!
Here is the patient (picture attached)

I temporarily removed 100k ohm gate to ground pulldown resistor.
What am i doing wrong?

Thank you!

That photo is not suitable. You need to draw a schematic of how everything is connected and post a phot of your drawing.

The more information you provide the more it seems most likely to be a power supply problem. Those problems often show symptons that are easily confused with programming problems.

To test this hypothesis provide the Arduino temporarily with a separate power supply - perhaps via the USB connector.


Hello Robin! Attached is a schematic of my setup
Im now convinced that its not the code, so perhaps i posted this question on a wrong forum tread. Could one of the moderators please move it?

I tried separate batteries for arduino and motors, didnt work, same issues
i tried running the robot from a power supply (which maxes out at 20A) and not a battery, didnt work

I feel like there is some RC circuit capacitance thing going on somewhere, which causes my pins to stop working after a certain time. Any ideas?

Is there any chance your program is running out of SRAM memory? That can cause strange symptoms.


Hey Robin!

I believe that im using about 30~33% of SRAM, so this is probably not the case. Although I never have filled up SRAM on any of my arduinos and ive been messing with them for quite some time now, and I dont know how the board would react if SRAM is almost full

So here is what i discovered today.
I soldered a jumper between transistors (MOSFETS) drain and source, effectively bypassing the transistors. I still experienced the same weird symptoms. Next, I removed 100k pulldown resistor that connects MOSFETS gate to ground. Surprisingly for me, I was able to turn that transistor on and off without any problems. Im guessing thats because i have that internal pullup resistor turned on and the pin impeadence is low enough. Doing so didnt stop the symptoms, but it has noticeably delayed them. Seriously its as if i had a resistor capacitor circuit somewhere with a long time constant which just kills connection to my pins.
Interestingly enough, removing mosfets from the circuit completely (e.g. desoldering wires from source and drain and soldering them together) appears to solve the problem. Sooo.... I dont really know what am I doing wrong
Could it be because im using pin D13 for my transistor gate? Pin 13 is kind of special because it has like an LED hooked up to it, if i remember correctly... maybe Ill try using another pin as my gate but I dont expect this to resolve my issue. Any thoughts?

Thanks !

As you seem to have isolated the problem to an electronics issue (rather than a code issue) I will bow out as I am very weak on electronics and non-existent on Mosfets.

Hope you find a solution.