Skip to main content

Mini 360 Degree Continuous Servo Code

Continuous servos have a different structure to them than regular servos.

A regular servo simply goes to t degree angle to tell it, where as continuous servos of course keep going around, so we must program them slightly differently, like so:

// Include the servo library

#include <Servo.h>

// Create the servo object

Servo myservo;

// Setup

void setup() {

 myservo.attach(9); // attach the servo to our servo object

 myservo.write(90); // stop the motor

}

// Main loop

void loop() {

 myservo.write(45); // rotate the motor counter-clockwise

 delay(5000); // keeps rotating for 5000 milliseconds (5 seconds)

 myservo.write(90); // stop the motor

 delay(5000); // stay stopped

 myservo.write(135); // rotate the motor clockwise

 delay(5000); // keeps rotating

}

Screenshot 2023-10-19 at 13.06.39.png