Hello
I'm building a robot using mainly DC motors, H Bridge controllers, controlled with Arduino Uno's. I managed to Fumble through writing sketches for all those but here's where the problem lies.
I'm using 1 Servo motor to control my head movement left and right and center. The servo moves to each position at full speed. I need the movements to ramp up and ramp down to each position. Is there a way to add this to my basic sketch below?
Please be kind any help would be greatly appreciated thank you.
#include <Servo.h>
Servo servoMain; // Define our Servo
void setup()
{
servoMain.attach(10); // servo on digital pin 10
}
void loop()
{
servoMain.write(90); // Turn Servo Left to 45 degrees
delay(5000); // Wait 1 second
servoMain.write(40); // Turn Servo Left to 0 degrees
delay(3000); // Wait 1 second
servoMain.write(90); // Turn Servo back to center position (90 degrees)
delay(5000); // Wait 1 second
servoMain.write(140); // Turn Servo Right to 135 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo Right to 180 degrees
delay(5000); // Wait 1 second
servoMain.write(40); // Turn Servo back to center position (90 degrees)
delay(3000); // Wait 1 second
servoMain.write(140); // Turn Servo Right to 135 degrees
delay(1000); // Wait 1 second
servoMain.write(90); // Turn Servo Right to 180 degrees
delay(5000); // Wait 1 second
servoMain.write(40); // Turn Servo back to center position (90 degrees)
delay(3000);
}