Duda Con Servos

Tengo una duda con los servos, hay alguna forma de que el servo este en una posicion inicial y aumente X grados al recibir una señal? porque hasta ahora solo encontre tutoriales para mover el servo a una posicion que se define, pero no para que por medio de un boton vaya moviendose, es todo y gracias de antemano.

En frió no veo el problema para no poder hacer eso. Por lo que dices cuando se pulse un botón hay que incrementar x grados su posición actual. Salu2

ionhs:
En frió no veo el problema para no poder hacer eso. Por lo que dices cuando se pulse un botón hay que incrementar x grados su posición actual. Salu2

Pero mi problema es que no he encontrado algun ejemplo de codigo de como hacer eso, todos los tutoriales que encuentro o son servos truncados con movimiento que no se detiene o se mueven a la posicion determinada.

hola yo tambien soy nuevo pero no le veo mucho problema solo tendras que coger dos botones y decirle que cuando pulses uno sume x grados y cuando pulses otro los restes. te creas una variable que lo que hace es guardar el valor de los grados que quieres de 0 a 180.

#include <Servo.h>
    Servo MiServo;
    int Senal;


    void setup(){
    MiServo.attach(9); Serial.begin(9600);
    }

    void loop() {
    //  Lee la señal del potenciómetro por el pin A0 (Pin 23 del ATMega328).
    Senal = analogRead(A0);
    //  Adapta la lectura de 1024 niveles a 180 niveles para el Servomotor.
    Senal = map(Senal, 0, 1023, 0, 179);
    //  Manda la señal corregida al Servomotor y a la Consola Serial.
    MiServo.write(Senal);
    Serial.println(Senal, DEC);
    //  Pequeño retardo para apreciar mejor las variaciones de la señal.
    delay(30);
    }

// Manda la señal corregida al Servomotor y a la Consola Serial.
MiServo.write(Senal);
Serial.println(Senal, DEC);
// Pequeño retardo para apreciar mejor las variaciones de la señal.
delay(30);
}

perdon que no se uqe he tocado, yo lo haría asi:

te creas una variable

int grados;
int boton+=2;
int boton-=3;

void setup()
{
configuras los puertos
}

void loop()
{
if (digitalRead(boton+)== HIGH){
grados++;
}
if (digitalRead(boton-)==HIGH)
{
grados--;
}

myservo......(grados);
}

yo lo haria algo parecido a esto. espero haberte sido de ayuda.
un saludo a todoso

Hola.

Yo estoy trabajando en un proyecto para hacer eso mismo que buscas tú a través del Ethernet shield para mover remotamente dos servos. El problema es soy novato en processing y me cuesta bastante.

Buscando info encontré un código para hacerlo a través del Serial Monitor que creo te ayudará.

/* 
 * NewSerialServo 
 * -------------- 
 * Servo control from the Serial port 
 * 
 * Alteration of the control interface to use < and > keys 
 * to slew the servo horn left and right.  Works best with 
 * the Linux/Mac terminal "screen" program. 
 * 
 * Created 10 December 2007 
 * copyleft 2007 Brian D. Wendt 
 * http://principialabs.com/ 
 * 
 * Adapted from code by Tom Igoe 
 * http://itp.nyu.edu/physcomp/Labs/Servo 
 */  
  
/** Adjust these values for your servo and setup, if necessary **/  
int servoPin     =  2;    // control pin for servo motor  
int minPulse     =  600;  // minimum servo position  
int maxPulse     =  2400; // maximum servo position  
int turnRate     =  100;  // servo turn rate increment (larger value, faster rate)  
int refreshTime  =  20;   // time (ms) between pulses (50Hz)  
  
/** The Arduino will calculate these values for you **/  
int centerServo;         // center servo position  
int pulseWidth;          // servo pulse width  
int moveServo;           // raw user input  
long lastPulse   = 0;    // recorded time (ms) of the last pulse  
  
  
void setup() {  
  pinMode(servoPin, OUTPUT);  // Set servo pin as an output pin  
  centerServo = maxPulse - ((maxPulse - minPulse)/2);  
  pulseWidth = centerServo;   // Give the servo a starting point (or it floats)  
  Serial.begin(9600);  
  Serial.println("      Arduino Serial Servo Control");  
  Serial.println("Press < or > to move, spacebar to center");  
  Serial.println();  
}  
  
void loop() {  
  // wait for serial input  
  if (Serial.available() > 0) {  
    // read the incoming byte:  
    moveServo = Serial.read();  
  
    // ASCII '<' is 44, ASCII '>' is 46 (comma and period, really)  
    if (moveServo == 44) { pulseWidth = pulseWidth - turnRate; }  
    if (moveServo == 46) { pulseWidth = pulseWidth + turnRate; }  
    if (moveServo == 32) { pulseWidth = centerServo; }  
  
    // stop servo pulse at min and max  
    if (pulseWidth > maxPulse) { pulseWidth = maxPulse; }  
    if (pulseWidth < minPulse) { pulseWidth = minPulse; }  
  
    // print pulseWidth back to the Serial Monitor (uncomment to debug)  
    // Serial.print("Pulse Width: ");  
    // Serial.print(pulseWidth);  
    // Serial.println("us");   // microseconds  
  }  
  
  // pulse the servo every 20 ms (refreshTime) with current pulseWidth  
  // this will hold the servo's position if unchanged, or move it if changed  
  if (millis() - lastPulse >= refreshTime) {  
    digitalWrite(servoPin, HIGH);   // start the pulse  
    delayMicroseconds(pulseWidth);  // pulse width  
    digitalWrite(servoPin, LOW);    // stop the pulse  
    lastPulse = millis();           // save the time of the last pulse  
  }  
}

Extraído de: principialabs.com - This website is for sale! - principialabs Resources and Information.

Aprovecho a ver si alguien puede ayudarme con ideas de en que me puedo estar equivocando al adaptar el anterior código para funcionar a través del ethernet shield. Mi código es este:

/*
  Web Server
 Proyecto de controlador web para camara
 */

#include  <SPI.h>
#include  <Ethernet.h>
#include  <Servo.h>  // Incluimos la libreria servo

//mac, IP
byte mac[] = { 0x00, 0x02, 0x0A, 0x0D, 0x06, 0x01 };
byte ip[] = { 192, 168, 1, 177 }; //IPAddress ip(192,168,1,177);
byte gateway[] = { 192, 168, 1, 1 }; // ip router
byte subnet[] = { 255, 255, 255, 0 }; // mascara subnet 
EthernetServer server(80); // puerto ethernet 

//pines out Trans
int zoom1 = 7;
int zoom2 = 8;
int foco1 = 2;
int foco2 = 3;
Servo servohor;  // creando el objeto servo para control
Servo servover;  // otro

int servoPinh     =  6;    // control pin for servo motor  
int minPulseh     =  600;  // minimum servo position  
int maxPulseh     =  2400; // maximum servo position  
int turnRateh     =  50;  // servo turn rate increment (larger value, faster rate)  
int refreshTimeh  =  100;   // time (ms) between pulses (50Hz)   
int centerServoh;         // center servo position  
int pulseWidthh;          // servo pulse width  
int moveServoh;           // raw user input  
long lastPulseh   = 0;    // recorded time (ms) of the last pulse 

int servoPinv     =  5;    // control pin for servo motor  
int minPulsev     =  1400;  // minimum servo position  
int maxPulsev     =  2000; // maximum servo position  
int turnRatev     =  50;  // servo turn rate increment (larger value, faster rate)  
int refreshTimev  =  100;   // time (ms) between pulses (50Hz)  
int centerServov;         // center servo position  
int pulseWidthv;          // servo pulse width  
int moveServov;           // raw user input  
long lastPulsev   = 0;    // recorded time (ms) of the last pulse  

boolean reading = false;
String readString;

void setup()
{
  
Serial.begin(9600);
//iniciar conexion
Ethernet.begin(mac, ip, gateway, gateway, subnet);
server.begin();

  pinMode(2, OUTPUT); //pin selected to control
  pinMode(3, OUTPUT); //pin selected to control
  pinMode(7, OUTPUT); //pin selected to control
  pinMode(8, OUTPUT); //pin selected to control
  pinMode(5, OUTPUT);  // Set servo pin as an output pin  
  centerServoh = maxPulseh - ((maxPulseh - minPulseh)/2);  
  pulseWidthh = centerServoh;   // Give the servo a starting point (or it floats)
  pinMode(6, OUTPUT);  // Set servo pin as an output pin  
  centerServov = maxPulsev - ((maxPulsev - minPulsev)/2);  
  pulseWidthv = centerServov;   // Give the servo a starting point (or it floats)




}

void loop()
{

EthernetClient client = server.available();
if (client) 
{
  while (client.connected()) 
  {
    if (client.available()) 
    {
      char c = client.read();
      if(readString.length() < 100) 
      {
      readString += c;
      Serial.print(c); 
      }
    if (c == '\n') 
      {
      

     //HTML creacion de formulario
          Serial.println(readString); 

          client.println("HTTP/1.1 200 OK"); 
          client.println("Content-Type: text/html");
          client.println();

          client.println("<HTML>");
          client.println("<HEAD>");
          client.println("<TITLE>Control Camara posicion zoom y foco</TITLE>");
          client.println("</HEAD>");
          client.println("<BODY>");

          client.println("<H1>Arduino, Control Camara posicion zoom y foco</H1>");
         
         //Servohor 
          client.println("<a href=\"/?right\"\">DERECHA</a>");
          client.println("<a href=\"/?center\"\">CENTRO</a>"); 
          client.println("<a href=\"/?left\"\">IZQUIERDA</a>"); 
          
          //servover
          client.println("<a href=\"/?up\"\">ARRIBA</a>");
          client.println("<a href=\"/?mid\"\">CENTRO</a>"); 
          client.println("<a href=\"/?down\"\">ABAJO</a>"); 
          
          // zoom y foco
          client.println("<a href=\"/?zoom1\"\">ZOOM+</a>");
          client.println("<a href=\"/?zoom2\"\">ZOOM-</a>");
          client.println("<a href=\"/?foco1\"\">FOCO+</a>");
          client.println("<a href=\"/?foco2\"\">FOCO-</a>");

          client.println("</BODY>");
          client.println("</HTML>");
 
          delay(100);
          //stopping client
          client.stop();
   
  
  

          ///////////////////// control arduino pin

     
          if(readString.indexOf("up") >0)  { pulseWidthv = pulseWidthv - turnRatev; } 
          if(readString.indexOf("mid") >0)   { pulseWidthv = centerServov; }
          if(readString.indexOf("down") >0)  { pulseWidthv = pulseWidthv + turnRatev; } 
          
            if (pulseWidthv > maxPulsev) { pulseWidthv = maxPulsev; } 
            if (pulseWidthv < minPulsev) { pulseWidthv = minPulsev; }
        
            if (millis() - lastPulsev >= refreshTimev) 
            {  
            digitalWrite(5, HIGH);   // start the pulse  
            delayMicroseconds(pulseWidthv);  // pulse width  
            digitalWrite(5, LOW);    // stop the pulse  
            lastPulsev = millis(); 
          }         // save the time of the last pulse  
        
         
          if(readString.indexOf("zoom1") >0)
          {
            digitalWrite(7, HIGH);
            delay (300);
            digitalWrite (7, LOW);                
            Serial.println("Zoom+");
          }
                    
          if(readString.indexOf("zoom2") >0)
          {
            digitalWrite(8, HIGH);
            delay (300);
            digitalWrite (8, LOW);            
            Serial.println("Zoom-");
          }
          
          if(readString.indexOf("foco1") >0)
          {
            digitalWrite(2, HIGH);
            delay (300);
            digitalWrite (2, LOW);             
            Serial.println("Foco+");
          }
          
          if(readString.indexOf("foco2") >0)
          {
            digitalWrite(3, HIGH);
            delay (300);
            digitalWrite (3, LOW);           
            Serial.println("Foco-");
          }
          
          //clearing string for next read
          readString="";

 
 //break;
          }
      }
   }
}
}

Gracias y un saludo