/*
Arduino | robotics-help
Random — 4/29/2026 4:44 PM
Friday, May 1, 2026 10:19 AM
Ok so the smaller increments helped and also adding some more
counterweight stabeld it out. it still jerks around but its better
DarwinWasWrong — Friday, May 1, 2026 11:19 PM
Another thing is adding in accel and deceleration steps.
if you move from 80 - 100 for example, you start slow, speed up,
then slow down again at the end
See https://github.com/leftCoast/LC_baseTools
Slow servo sweep using Jim Lee's LC_baseTools
DarwinWasWrong — 5/2/2026 10:59 PMSaturday, May 2, 2026 10:59 PM
The radio Head ASK library prevents STANDARD servo libraries due to timer use.
jim lee — 1:07 AMWednesday, May 6, 2026 1:07 AM
Just use blinker() from baseTools to drive your servos. Easy peasy.
Map 0,180,1,2 for pulse, set period to about 15
*/
#include <slowServo.h>
#include <mapper.h>
const int SERVO_PIN = 2;
slowServo servo(SERVO_PIN); // create slow servo
mapper speedMapper(0, 1023, 50, 5); // map speed between 50mS and 5mS
mapper cwAngleMapper(0, 1023, 90, 180); // map angle from 90 to 180
mapper ccwAngleMapper(0, 1023, 0, 90); // map angle from 0 to 90
void setup() {
Serial.begin(115200);
servo.begin();
}
void loop() {
static bool isTarget = false;
idle(); // idle yields to LC_baseTools library functions
int speed = speedMapper.map(analogRead(A2));
int cwTarget = cwAngleMapper.map(analogRead(A0));
int ccwTarget = ccwAngleMapper.map(analogRead(A1));
servo.setMsPerDeg(speed);
if (!servo.moving()) { // when the servo reaches its target...
isTarget = !isTarget;
servo.setDeg(isTarget ? ccwTarget : cwTarget);
Serial.print("Servo moving ");
Serial.print(isTarget ? "CCW to " : "CW to ");
Serial.print(isTarget ? ccwTarget : cwTarget);
Serial.print(" at ");
Serial.print(speed);
Serial.println("ms per step. ");
}
}
Speed
CCW Angle
CW Angle