The truth is out there! (Servo control)

I know it is but I can’t find it. I just want to know if with Blynk using nodemcu (esp8266 12-e) if I can control a futaba servo (3003) via a button or slider widget to give me smooth motion 0-180 degrees (and 180-0) . Also, am I able to control the speed of the servo? I was able to do this with an Arduino Uno R3, but not having any luck with Blynk.
I am trying to control a capacitor that is used to tune a magnetic loop antenna.
If I have to use timers, I’m not sure how to deploy.
Thanks for the help

It is all about the code you use, not really a Blynk thing, that is just the GUI.

This is just one way…

And an alternative of varying the timer

Thank you sooo much! After posting this I came across your #4 sketch, implemented it and it works beautifully!! I’ve been at this for about 30h and found you’re the only one who has described it well. Now , all I have to do is when I stop the servo rotation (button off) , I want to be able to turn button on and control rotation in opposite direction . As it is now, the servo goes to the start point directly. Any suggestions? Do I need separate slider in reverse direction?
Your help is really greatly appreciated.

It will all be in the coding, using logic and counters. And probably dozens of ways to code it :stuck_out_tongue:

I would recommend looking at the 2nd way of handling a variable timer and create two servo control routines, one for clockwise and another for counterclockwise… but include something that tracks the servo position so that it can switch direction from it’s last known position. Then a simple logic flag that flip flops between them each time the switch is turned on.

I’ve already created servobutton2 , am having problems, hopefully I can figure it out. I’ve got to finish this otherwise the antenna gets taken away…Haha

Thanks again for your kind help!

I would also consider using a Stepper motor… much more fine control. You will need a controller board, but they are dirt cheap.

The Futaba (3003) is a stepper servo I believe. It rotates from 0-180 degrees which is perfect for this application.
I have tried your sketch without a controller board and it works well. So far, in the 1 direction the servo can go, the resolution is good. I essentially need the servo to move the air variable capacitor to turn to establish antenna resonance. That spot is hard to find. So, when in the vicinity , I then need the servo to rotate on my command forward and reverse at a slower speed ( controlled by the slider widget) to find the sweet spot.
Yes, I am a licensed ham operator (not that old) that fell into Arduino and programming.

Thanks for the comeback.

It is just a standard servo… a stepper motor is a different beast all together. While a stepper can be more precise, it is more complex to use… either should work for your application.

Thanks Gunner,

Still working on you code but no success. if I can get it to compile and run , I’ll post the code here for everyone to see.
I’ll of course credit you with the sketch.

ok…it’s all in the code but when I stop the servo I cannot get it to move (as per the slider speed) in the other direction.
I tried 2 button access=no luck it confounds the whole sketch.
I want to stop the servo from automatically going back to 30 degrees and control it myself .
Any input would help, I’ve failed except for learning how timers work :slight_smile:


Hey all,

I don’t want to change Gunner’s original sketch #4 , it works well.
When I stop the servo and restart it , it moves back to a position of ten.
All I want to do is when servo is stopped and restarted , for it to go in reverse direction at same
speed it went forward originally… I’m stumped.


Ps… I would even settle for how to change the variable speed timer while servo is in motion to prevent the servo from going back to the beginning. ie change the servo speed on the fly.

Thanks to all

Hi all,

I’m creating a servo project using the esp8266 12-e module.
I want to move the servo clockwise and counterclockwise at variable speeds.
What would happen if I don’t program in the timer function?
Would the servo rattle when idle?. Is it possible the the wifi connection would be broken?
I’ve researched the timer function , and I’m not sure I understand it’s capabilities fully without it after
making sketches for the UNO R3 only.

Thanks for your input!

@learner: Have a look at this this post and give it a try.


I have had conversations with Gunner about that. (under hardware).
I have tried to rework the sketch because I think it’s excellent. However,
I can’t. No matter what I change , when the servo button is turned off and restarted, the servo goes back to (10).
What I’m trying to do is have the servo go back from where it’s last position was (counterclockwise) at the same speed it went clockwise when the servo button is turned on again.

Hope this clarifies and thanks for the help.

problem solved… sometimes the answer is staring you in the face.

I eliminated line 53 of Gunners #4 sketch SrvoPos =(10).
Now I can control the speed of the servo without it going back to 10. I can reset the speed at any angle.
Now the easy part to create a counterclockwise button.

Thanks to all for your help.

Why not post this in your original post(s), and change that to solved? Having it here makes no sense, and doesn’t really help anyone as they will have no clue what you are even talking about. There is no need to create multiple topics when they are all about the same thing?

1 Like

@learner Don’t forget to read ALL of the post and sketch comments when trying out my examples :stuck_out_tongue_winking_eye:

PS, I have merged all of your related topics. In the future, please do as instructed above and keep relevant comments and posts to their respective topic.

ok guys, I flubbed it. When in my postings I was having trouble indicating it was solved so I created it under ‘solved’.

Just like coding, one learns from their mistakes. thanks for the heads up.