Go Down

Topic: Incremental control of servo motor (Read 1 time) previous topic - next topic


Mar 26, 2014, 12:01 pm Last Edit: Mar 26, 2014, 12:03 pm by atorpred Reason: 1
Hello all!

I'm looking for way to control servo motor incrementaly. With that i mean, that if i want to move servo, then i specify just change of angle, instead absolute position.

In my particular case:
When loop starts frst time servo position needs to be, lets say 90 degrees. Then is required change for +30 degrees, so : 90+30= 110, and then position 110 degrees must be send to servo and stored. When loop repeats it takes 110 degrees for current angle, and if next required change is 50 degrees, then calc 110+50=160 and write pos= 160 deg.

I may try eeprom, but as far as i know, that type of memory is for more temporary data...
So, i would really appreceate every opinion!

best regards


so : 90+30= 110

What number base are you working in there?

What's wrong with RAM, or does this system have to hold position across a reset?
"Pete, it's a fool (who) looks for logic in the chambers of the human heart." Ulysses Everett McGill.
Do not send technical questions via personal messaging - they will be ignored.
I speak for myself, not Arduino.


Oh, i'm sorry, i meant 90+ 30=120  :smiley-roll-sweat:
No permanent storing is not needed.

Would you be kind and explain me how to write code to store and read from ram in my case?  :D



Would you be kind and explain me how to write code to store and read from ram in my case?

Code: [Select]
int oldPos = 30;
int incPos = 90;
int newPos = oldPos + incPos;
The art of getting good answers lies in asking good questions.


Ok, thats how change it. And it works!

Code: [Select]

#include <Servo.h>
Servo servo1;

int newPos;
int oldPos = 90;
int incPos;

void setup()

void loop()
incPos = Serial.read();
newPos = oldPos + incPos;
oldPos = newPos;
delay (100);

Go Up