How to switch off Servo

Hi, i'm using a servo, modified by me to complete 360 degrees angles, but now i don't how to to switch it off by using an IR signal. I searched on this Forum, but i found only one about a Servo with external circuit. Can someone explain me the code to stop the Servo, considering i modified it?

Don't you think it might be a little tricky to answer your question since you haven't told us how you modified the servo?

Can you also post the code you have tried and explain what you want it to do and what it actually does.

...R

So you modified a standard servo to which, a 360 degree servo or a continuous rotation servo? There is a difference and the answer is different depending on what you ended up with.

Can someone explain me the code to stop the Servo, considering i modified it?

Depends on how you modified the servo. If the servo still has its pot installed, then send the servo a 1500us command and the carefully adjust the pot until the servo stops moving. Then 1500us will be the neutral stop command. If you removed the pot and installed resistors, then you will need to experiment to find the neutral stop point. Below is some code that will allow you to experiment to find the servo neutral point.

// zoomkat 3-28-14 serial servo incremental test code
// using serial monitor type a character (s to increase or a 
// to decrease) and enter to change servo position 
// use strings like 90x or 1500x for new servo position 
// for IDE 1.0.5 and later
// Powering a servo from the arduino usually *DOES NOT WORK*.

#include<Servo.h>
String readString;
Servo myservo;
int pos=1500; //~neutral value for continous rotation servo
//int pos=90;

void setup()
{
  myservo.attach(7, 400, 2600); //servo control pin, and range if desired
  Serial.begin(9600);
  Serial.println("serial servo incremental test code");
  Serial.println("type a character (s to increase or a to decrease)");
  Serial.println("and enter to change servo position");
  Serial.println("use strings like 90x or 1500x for new servo position");
  Serial.println();
}

void loop()
{
  while (Serial.available()) {
    char c = Serial.read();  //gets one byte from serial buffer
    readString += c; //makes the string readString
    delay(2);  //slow looping to allow buffer to fill with next character
  }
  if (readString.length() >0) {
    if(readString.indexOf('x') >0) { 
      pos = readString.toInt();
    }

    if(readString =="a"){
      (pos=pos-1); //use larger numbers for larger increments
      if(pos<0) (pos=0); //prevent negative number
    }
    if (readString =="s"){
      (pos=pos+1);
    }

    if(pos >= 400) //determine servo write method
    {
      Serial.println(pos);
      myservo.writeMicroseconds(pos);
    }
    else
    {   
      Serial.println(pos);
      myservo.write(pos); 
    }
  }
  readString=""; //empty for next input
}

retrolefty: So you modified a standard servo to which, a 360 degree servo or a continuous rotation servo? There is a difference and the answer is different depending on what you ended up with.

i modified a standard servo (the one that rotate doing 180 degree) into a continuous servo, anyway i solved, i'll post soon the code.

I solved.
this is how:

#include <Servo.h>
#include <IRremote.h>

int IRrec=2;  
int greenPIN=3;
boolean motoStat=false;
Servo motore_l;     //definisce un oggetto motore
Servo motore_r;
decode_results results;    //decodifica i risultati IR
IRrecv irrecv(IRrec);      //boh, chiedi a Niccolo'

void setup(){
  pinMode(greenPIN, OUTPUT);
  irrecv.enableIRIn();     //inizializza il ricevitore
}

void loop(){
  if (irrecv.decode(&results)){      //se vengono decodificati dei segnali esegui {}
   
    if (results.value==16744575)
    {
        if (motoStat==false)
        {
          motore_l.attach(9);
          motore_r.attach(10);
          digitalWrite(greenPIN, HIGH);
          motoStat=true;
        }
        else
        {
          motore_l.detach();
          motore_r.detach();
          digitalWrite(greenPIN, LOW);
          motoStat=false;
        }
    }
    
    if (results.value==16711935)
    {    //se il valore e' tasto sinistro gira verso 0
      motore_l.write(0);
      motore_r.write(180);
    }
    if (results.value==16756815)     //se il valore e' tasto destro gira verso 180
    {  
      motore_l.write(180);
      motore_r.write(0);
    }
    irrecv.resume();                 //ricevi altri segnali
  }
}

Tell me if is this the smartest way to control servo status

I can't work out what your code is trying to do - perhaps you can explain?

The usual way to control a continuous rotation servo is to figure out the value for servo.writeMicroseconds() will cause it to stop. The stop number will be close to 1500, but every servo is different so you need to experiment.

Then lower numbers will cause it to rotate one way and numbers above the stop number will make it go the other way. The farther the number is from the stop number the faster the servo will rotate.

...R