SoftwareServo.h not being identified !

hello guys,
i am trying to drive 2 servos on the same arduino so i look a bit and found the SoftwareServo.h library so i am trying it and seems it’s not being identified on my script and it still giving me this error : Servo does not name a type !
so what is the solution ?
(i tried the ServoTimer2 and and changed from Servo type to ServoTimer2 and same problem)

and thanks in advance

#include <VirtualWire.h>
#include <SoftwareServo.h>

int enablePin = 5;
int in1Pin = 4;
int in2Pin = 3;

int servoSteering = 9;
Servo servo;

void setup()
{
  Serial.begin(9600);	// Debugging only
  Serial.println("Receiving");
  pinMode(13,OUTPUT);
  // Initialise the IO and ISR
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);	 // Bits per sec
  vw_set_rx_pin(6);
  vw_rx_start();       // Start the receiver PLL running
  
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
  Servo.attach(servoSteering);
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  if (vw_get_message(buf, &buflen)) // Non-blocking
  { 
    digitalWrite(13, HIGH); // Indicate data is being received
    int valBrakes = atoi(strtok((char*)buf, ","));  // Look for a comma, the return the data before it.
    
    
    int valThrottle = atoi(strtok(NULL, ",")); // same as above
    
    int valSteering = atoi(strtok(NULL, ",")); // same as above
    int angle = valSteering / 6; // 0 to 180-ish
    Servo.write(angle);
    
    //int temp3 = atoi(strtok(NULL, ".")); // Look for a period, then return data before it.
    Serial.print(valBrakes); // X axis
    Serial.print(", ");
    Serial.print(valThrottle); // Y axis
    Serial.print(", ");
    //Serial.print(temp3); // Z axis
    Serial.println();
    
    setMotor(valThrottle, valBrakes);
  }
  else digitalWrite(13, LOW); // No data received
}

void setMotor(int throttle, int brake)
{
  int pedal ;
  if(throttle){
    pedal = throttle;
    analogWrite(enablePin, throttle);
  }else if (brake){
    pedal = brake;
    analogWrite(enablePin, brake);
  }
  
  digitalWrite(in1Pin, throttle);
  digitalWrite(in2Pin, brake);
}

It is your lack of attention to detail. You have over 500 posts here, and you still do not post you code?

SurferTim: It is your lack of attention to detail. You have over 500 posts here, and you still do not post you code?

sorry for that again

No problem. You need to refer to that as servo, not Servo.

// change this
  Servo.attach(servoSteering);
// to this
  servo.attach(servoSteering);

SurferTim:
No problem. You need to refer to that as servo, not Servo.

// change this

Servo.attach(servoSteering);
// to this
  servo.attach(servoSteering);

ok done but still giving me an error which is the same : Servo does not name a type

Servo servo;

Then you may be using the wrong declaration or include file. Is there a reason you are not using the standard servo library included with the IDE?

#include <Servo.h>

http://arduino.cc/en/Reference/Servo
http://arduino.cc/en/Reference/ServoAttach

it because it give me this error :
Servo\Servo.cpp.o: In function __vector_11': D:\Arduino\libraries\Servo/Servo.cpp:103: multiple definition of __vector_11’
VirtualWire\VirtualWire.cpp.o:D:\Arduino\libraries\VirtualWire/VirtualWire.cpp:588: first defined here

so i searched for it on google and found that they give a solution which is to use SoftwareServo.h which is updated to be used with a library that uses the same timer

firashelou:

SurferTim: No problem. You need to refer to that as servo, not Servo.

// change this
  Servo.attach(servoSteering);
// to this
  servo.attach(servoSteering);

ok done but still giving me an error which is the same : Servo does not name a type

Servo servo;

Why have you still got a reference to Servo in your code when it should be servo ?

i changed everything to servo even this one but it gave me the same error servo does not name a type so i change this line again to Servo

// change this
Servo servo;
// to this
SoftwareServo servo;

I downloaded the SoftwareServo library, installed it in the right place, fixed all the issues with your code, and it compiles just fine. The problem is on your end.

SurferTim: // change this Servo servo; // to this SoftwareServo servo;

same error SoftwareServo does not name a type

PaulS: I downloaded the SoftwareServo library, installed it in the right place, fixed all the issues with your code, and it compiles just fine. The problem is on your end. i put it in libraries

can you send me please the one you downloaded , maybe mine has something not correct

  1. Attach the cpp and .h files to your post

  2. Post the actual (copy and paste - code tags) not your summary!

  3. Post your upto date code again in code tags.

Mark

this is the last modification of my codes

#include <VirtualWire.h>
#include <SoftwareServo.h>

int enablePin = 5;
int in1Pin = 4;
int in2Pin = 3;

int servoSteering = 9;
SoftwareServo servo;

void setup()
{
  Serial.begin(9600);	// Debugging only
  Serial.println("Receiving");
  pinMode(13,OUTPUT);
  // Initialise the IO and ISR
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);	 // Bits per sec
  vw_set_rx_pin(6);
  vw_rx_start();       // Start the receiver PLL running
  
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
  servo.attach(servoSteering);
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  if (vw_get_message(buf, &buflen)) // Non-blocking
  { 
    digitalWrite(13, HIGH); // Indicate data is being received
    int valBrakes = atoi(strtok((char*)buf, ","));  // Look for a comma, the return the data before it.
    
    
    int valThrottle = atoi(strtok(NULL, ",")); // same as above
    
    int valSteering = atoi(strtok(NULL, ",")); // same as above
    int angle = valSteering / 6; // 0 to 180-ish
    servo.write(angle);
    
    //int temp3 = atoi(strtok(NULL, ".")); // Look for a period, then return data before it.
    Serial.print(valBrakes); // X axis
    Serial.print(", ");
    Serial.print(valThrottle); // Y axis
    Serial.print(", ");
    //Serial.print(temp3); // Z axis
    Serial.println();
    
    setMotor(valThrottle, valBrakes);
  }
  else digitalWrite(13, LOW); // No data received
}

void setMotor(int throttle, int brake)
{
  int pedal ;
  if(throttle){
    pedal = throttle;
    analogWrite(enablePin, throttle);
  }else if (brake){
    pedal = brake;
    analogWrite(enablePin, brake);
  }
  
  digitalWrite(in1Pin, throttle);
  digitalWrite(in2Pin, brake);
}

SoftwareServo.cpp (3.18 KB)

SoftwareServo.h (1.18 KB)

maybe mine has something not correct

I'd say that is is more likely (approaching certainty) that you have not installed the library in the correct place (or you didn't restart the IDE after installing the SoftwareServo library).

PaulS:

maybe mine has something not correct

I’d say that is is more likely (approaching certainty) that you have not installed the library in the correct place (or you didn’t restart the IDE after installing the SoftwareServo library).

ok after i restarted the IDE it give me this error : expected unqualified-id before ’ . ’ token
in this line of codes : SoftwareServo.attach(servoSteering);

here is my last update :

#include <VirtualWire.h>
#include <SoftwareServo.h>

int enablePin = 5;
int in1Pin = 4;
int in2Pin = 3;

int servoSteering = 9;
SoftwareServo servo;

void setup()
{
  Serial.begin(9600);	// Debugging only
  Serial.println("Receiving");
  pinMode(13,OUTPUT);
  // Initialise the IO and ISR
  //vw_set_ptt_inverted(true); // Required for DR3100
  vw_setup(2000);	 // Bits per sec
  vw_set_rx_pin(6);
  vw_rx_start();       // Start the receiver PLL running
  
  pinMode(in1Pin, OUTPUT);
  pinMode(in2Pin, OUTPUT);
  pinMode(enablePin, OUTPUT);
  
  SoftwareServo.attach(servoSteering);
}

void loop()
{
  uint8_t buf[VW_MAX_MESSAGE_LEN];
  uint8_t buflen = VW_MAX_MESSAGE_LEN;

  if (vw_get_message(buf, &buflen)) // Non-blocking
  { 
    digitalWrite(13, HIGH); // Indicate data is being received
    int valBrakes = atoi(strtok((char*)buf, ","));  // Look for a comma, the return the data before it.
    
    
    int valThrottle = atoi(strtok(NULL, ",")); // same as above
    
    int valSteering = atoi(strtok(NULL, ",")); // same as above
    int angle = valSteering / 6; // 0 to 180-ish
    SoftwareServo.write(angle);
    
    //int temp3 = atoi(strtok(NULL, ".")); // Look for a period, then return data before it.
    Serial.print(valBrakes); // X axis
    Serial.print(", ");
    Serial.print(valThrottle); // Y axis
    Serial.print(", ");
    //Serial.print(temp3); // Z axis
    Serial.println();
    
    setMotor(valThrottle, valBrakes);
  }
  else digitalWrite(13, LOW); // No data received
}

void setMotor(int throttle, int brake)
{
  int pedal ;
  if(throttle){
    pedal = throttle;
    analogWrite(enablePin, throttle);
  }else if (brake){
    pedal = brake;
    analogWrite(enablePin, brake);
  }
  
  digitalWrite(in1Pin, throttle);
  digitalWrite(in2Pin, brake);
}
// the declaration
SoftwareServo servo;

// the attach in setup()
  servo.attach(servoSteering);

SurferTim: ``` // the declaration SoftwareServo servo;

// the attach in setup()   servo.attach(servoSteering);

ok i changed it in both setup and loop and now the error is : error compiling with : D:\Arduino\libraries\SoftwareServo\SoftwareServo.cpp: In static member function 'static void SoftwareServo::refresh()': D:\Arduino\libraries\SoftwareServo\SoftwareServo.cpp:73: error: 'millis' was not declared in this scope D:\Arduino\libraries\SoftwareServo\SoftwareServo.cpp:106: error: 'digitalWrite' was not declared in this scope D:\Arduino\libraries\SoftwareServo\SoftwareServo.cpp:108: error: 'TCNT0' was not declared in this scope D:\Arduino\libraries\SoftwareServo\SoftwareServo.cpp:123: error: 'digitalWrite' was not declared in this scope

SoftwareSevo.h contains:

#include <WProgram.h>

You need to upgrade the library for post 1.0 use.