Go Down

Topic: g_ServoOut.update() (Read 614 times) previous topic - next topic

CanDo

the  g_ServoOut.update() in the loop wont work. in the setup the servo moves to  the middle and stays there.
anybody knows why?

Code: [Select]
#include <ServoOut.h>
#include <Timer1.h>
#define SERVOS 1

uint8_t  g_pinsOut[SERVOS] = {
  2};    // Output pins
uint16_t g_input[SERVOS];                     // Input buffer for servoOut, microseconds
uint8_t  g_work[SERVOOUT_WORK_SIZE(SERVOS)];  // we need to have a work buffer for the ServoOut class
rc::ServoOut g_ServoOut(g_pinsOut, g_input, g_work, SERVOS);
int dir = 1;
int i=1500;

void setup()
{
  rc::Timer1::init();
  Serial.begin(9600);
  for (uint8_t i = 0;  i < SERVOS; ++i)
  {

    // set up output pins
    pinMode(g_pinsOut[i], OUTPUT);

    // put them low
    digitalWrite(g_pinsOut[i], LOW);

    // fill input buffer, convert raw values to normalized ones
    g_input[i] = (1500);
  }
  g_ServoOut.start();
}

void loop()
{
  delay(100);
  switch (dir){
    case 0:
    if (i>1000)   
   {       
Serial.println("dir 0");
     g_input[1] = i;
     --i;
  }
  else
  {
    dir=1;
  }
  case 1:
    if (i<2000)   
  {       
     Serial.println("dir 1");
    g_input[1] = i;
    ++i;
  }
  else
  {
    dir=0;
  }
  }
  Serial.println(g_input[1]);
  g_ServoOut.update();

}


Robin2

What does the ServoOut library do that is different from the regular Sevo library?

Where did you get it - do you have a link?

...R
Two or three hours spent thinking and reading documentation solves most programming problems.


Robin2


its thr rc library...


You haven't said what is different about it and why you are using it rather than the regular Servo library that comes with the Arduino IDE and with which most people are familiar.

...R
Two or three hours spent thinking and reading documentation solves most programming problems.

Go Up