Verify Sketch Fails

I am unable to verify any of my saved sketches. I have tried with 2 Windows computers and an iMac and I keep getting the same error. I have upgraded to the latest Arduino IDE. Same problem.

The #include is highlighted pink.

Arduino: 1.8.19 (Mac OS X), Board: "Arduino Nano, ATmega328P"

Switched_6_SlowServoToggle_corrected_sketch_feb21_2020_RH:5:10: fatal error: SoftwareServo.h: No such file or directory
#include <SoftwareServo.h>
^~~~~~~~~~~~~~~~~
compilation terminated.
exit status 1
SoftwareServo.h: No such file or directory

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

And you have this file somewhere ?

I think It's part of the sketch. The gent who created all the servo sketches didn't include the SoftwareServo.h file... I don't recall. It's going on 4 years ago.

Well google send me here and it looks like it is rather old and hasn't been updated in 7 years. It pre-dates IDE 1.x.x there is a few topics discussing it here

It may be worth looking at a more modern implementation of controlling a servo. What is it exactly (and i mean, please describe in as much detail as possible, which parts how connected, how powered and with what code) what you are trying to do ?

I use them for model railroad turnouts. Turnouts are controlled with uno and nano. Nothing too complicated

In that case you should probably just go for the standard Servo.h library, (builtin with the IDE) and start out from the examples that come with it.

Would just removing Software from Servo.h in the sketch work?

Who knows, i do not know the sketch since you haven't posted it, but as an approach it is wrong in my opinion.
Ok so you found something online, but it's ancient and no longer supported, may the current Servo.h library is backwards compatibel with that SoftwareServo.h but maybe not. Investigating the origins is not productive.

What you are trying to do is not complicated, You should be able to manage with some help, but it is required that you understand what you are trying to do. Trying out the examples will be a good approach.

If you want to do something with an Arduino and your try is : " i found this, but it doesn't work, can i swap this for that ? "

I mean seriously, you found something that doesn't work. If you look a bit longer or better, you may find something that does, but you will not have any understanding of what it is you do.

OK. Many thanks for your time. I'll have a look when I get home. Have a good eve

[code]
//   Switched_34_SlowServosToggle.ino
//   Mega2560 34 Switched Servos with Toggle Switches
//   G. Bunza 2020
//
#include <SoftwareServo.h>
#define numservos 34                     // Number of Servos
SoftwareServo  servo[numservos] ;
int servo_delay =  40;                   // Servo inter-step delay in milliseconds
int i,j,k,l;
int pins [ ]= {36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,
               56,57,58,59,60,61,62,63,64,65,66,67,68,69};          // Toggle Switch pins (34)
int spins [ ]= {2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,
               22,23,24,25,26,27,28,29,30,31,32,33,34,35};       // Servo pins (34)
int sstart [ ]= {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
                 25,25,25,25,25,25,25,25,25,25,25,25,25,25};                // Servo Start Positions
int sstop [ ]= {160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,160,
                160,160,160,160,160,160,160,160,160,160,160,160,160,160};   // Servo Stop Positions
int spos [ ] = {25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,25,
                25,25,25,25,25,25,25,25,25,25,25,25,25,25};       // Servo Current Positions initially should be same as sstart[]
//
void setup() {
  for (i=0; i<numservos; i++)  {
    servo[i].attach (spins[i]);         // Set up servo controls
    servo[i].write(sstart[i]);          // Set each servo to start position
  }
   pinMode(pins[i],INPUT_PULLUP);       // Initialize Toggle pins
}
void loop() {
  SoftwareServo::refresh();              // Must Refresh the Internal Servo Contro
  for (i=0; i<numservos; i++)  {
    if (digitalRead(pins[i])==HIGH) {    // Check if a Pushbutton is pressed
        if (sstart[i]< sstop[i]) {
          for (j=spos[i]; j >= sstart[i]; j--) {
            servo[i].write(j);
            delay (servo_delay);
          }
        }  else {                         //Now sstart[] > sstop[]
            for (j=spos[i]; j <= sstart[i]; j++) {
              servo[i].write(j);
              delay (servo_delay);
          }
        }
      spos[i] = sstart[i];
      } else  {                          // Pinval[i]==false Move the servo to sstop[i]
          if (sstart[i] < sstop[i]) {
          for (j=spos[i]; j <= sstop[i]; j++) {
            servo[i].write(j);
            delay (servo_delay);
          }
        }  else {                         //Now sstart[] > sstop[]
            for (j=spos[i]; j >= sstop[i]; j--) {
              servo[i].write(j);
              delay (servo_delay);
          }
        }
      spos[i] = sstop[i];
      }
    }
}

 
[/code]

The Servo.h library comes with a knob example

#include <Servo.h>

Servo myservo;  // create servo object to control a servo

int potpin = 0;  // analog pin used to connect the potentiometer
int val;    // variable to read the value from the analog pin

void setup()
{
  myservo.attach(9);  // attaches the servo on pin 9 to the servo object
}

void loop() 
{ 
  val = analogRead(potpin);            // reads the value of the potentiometer (value between 0 and 1023) 
  val = map(val, 0, 1023, 0, 180);     // scale it to use it with the servo (value between 0 and 180) 
  myservo.write(val);                  // sets the servo position according to the scaled value 
  delay(15);                           // waits for the servo to get there 
} 

Looks like the syntax is exactly the same.

As far as i know it's built into the IDE and does not require installation.

So yes in that case it should. Let us know the result.

I tried :wink: It breaks its neck over SoftwareServo::refresh(). I do not have the time at this moment to analyse and write an alternative. Maybe you have; else OP must do it :wink:

Servo.h doesn't need that at all, it can just be omitted.

Something similar goes for both instances of

delay (servo_delay);

Theoretically it isn't needed at all, but some delay to slow the loop down as in the example is a good idea.

delay(15);                           // once per loop()

I have tried your suggestions, and I thank you for your time.
No change.
The sketch files I have saved are 3-4 yrs old... if not more and they all pretty much do the same error regardless if I use the old IDE or the new one. Has Arduino changed something along the way?
I can't understand why ALL the files fail to validate. The sketches I have loaded onto the Mega and Nanos still work.

Have you tried the examples that come with Servo.h ?

Probably significantly older.

Drop the SoftwareServo.h and start fresh.

The only SoftwareServo (with no h) is on line 24. When removed I get a HardwareServo error (line 7). When I remove that I get a servo error.

It is not to remove but to replace, but it seems you are messing about without knowing what to do, and you don't post the sketch that is causing the issue

#include <Servo.h>
#define numservos 34                     // Number of Servos
Servo  servo[numservos] ;
int servo_delay =  40;                   // Servo inter-step delay in milliseconds
int i, j, k, l;
int pins [ ] = {36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55,
                56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69
               };          // Toggle Switch pins (34)
int spins [ ] = {2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
                 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35
                };       // Servo pins (34)
int sstart [ ] = {25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
                  25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
                 };                // Servo Start Positions
int sstop [ ] = {160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160,
                 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160, 160
                };   // Servo Stop Positions
int spos [ ] = {25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25,
                25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25, 25
               };       // Servo Current Positions initially should be same as sstart[]
//
void setup() {
  for (i = 0; i < numservos; i++)  {
    servo[i].attach (spins[i]);         // Set up servo controls
    servo[i].write(sstart[i]);          // Set each servo to start position
  }
  pinMode(pins[i], INPUT_PULLUP);      // Initialize Toggle pins
}
void loop() {

  for (i = 0; i < numservos; i++)  {
    if (digitalRead(pins[i]) == HIGH) {  // Check if a Pushbutton is pressed
      if (sstart[i] < sstop[i]) {
        for (j = spos[i]; j >= sstart[i]; j--) {
          servo[i].write(j);
          delay (servo_delay);
        }
      }  else {                         //Now sstart[] > sstop[]
        for (j = spos[i]; j <= sstart[i]; j++) {
          servo[i].write(j);
          delay (servo_delay);
        }
      }
      spos[i] = sstart[i];
    } else  {                          // Pinval[i]==false Move the servo to sstop[i]
      if (sstart[i] < sstop[i]) {
        for (j = spos[i]; j <= sstop[i]; j++) {
          servo[i].write(j);
          delay (servo_delay);
        }
      }  else {                         //Now sstart[] > sstop[]
        for (j = spos[i]; j >= sstop[i]; j--) {
          servo[i].write(j);
          delay (servo_delay);
        }
      }
      spos[i] = sstop[i];
    }
  }
}

This compiles for a Mega. Don't know if it works, but that is a different matter, actually i have some issues with the pin nrs. Mega has no more pins than 54.

Replace with WHAT?

Yes you are correct. I don't know what to do! That is why I'm on this forum. I have posted the sketch. They all do the same!
This forum used to be helpful

Wow. An updated topic shows up on the forum about every five seconds. Assume half of them are the OP (you). You call that the opposite of helpful? Did you try the advice everyone gave to you, or did you pre-judge everyone is unhelpful because they didn't make you a biscuit to order? You never acknowledged my input.