programming a 360 servo to spin non stop

Hi i am trying to make a 360 servo spin continuous with an on off button, i would appreciate it if someone can make a code i can use for that. :slight_smile:

Please try to code this yourself

Look at the examples in the IDE
Learn to read the state of an input pin
A continuous rotation servo, if that is what you have, will continue to spin once you write a value to it and stop when you write zero (or something close) to it

Some servo test code you can use to understand how your continuous rotation servo operates.

// zoomkat 7-30-10 serial servo test
// type servo position 0 to 180 in serial monitor
// for writeMicroseconds, use a value like 1500
// Powering a servo from the arduino usually *DOES NOT WORK*.

String readString;
#include <Servo.h> 
Servo myservo;  // create servo object to control a servo 

void setup() {

void loop() {

  while (Serial.available()) {

    if (Serial.available() >0) {
      char c =;  //gets one byte from serial buffer
      readString += c; //makes the string readString

  if (readString.length() >0) {
    int n = readString.toInt();