So I haven't encountered this before, but I'm trying to use VarSpeedServo in lieu of Servo.h.
My code verifies but when uploading says it won't compile for arduino nano. I havent changed any setting and indeed if I load blink (or anything) in another window it loads to this same board just fine. I had been operating under the assumption that a library compatible with arduino uno would also be compatible with a nano- is that wrong? The text from the status window relays the following (excerpt):
C:\Users\saluk\Documents\Arduino\libraries\VarSpeedServo" "C:\Users\saluk\Documents\Arduino\libraries\VarSpeedServo\VarSpeedServo.cpp" -o nul
Alternatives for WProgram.h: []C:\Users\saluk\Documents\Arduino\libraries\VarSpeedServo\VarSpeedServo.cpp:56:10: fatal error: WProgram.h: No such file or directory
ResolveLibrary(WProgram.h) #include <WProgram.h>
-> candidates: [] ^~~~~~~~~~~~
compilation terminated.
Using library VarSpeedServo in folder: C:\Users\saluk\Documents\Arduino\libraries\VarSpeedServo (legacy)
exit status 1
Error compiling for board Arduino Nano.
here's my code:
/*
* Elbow(3):
* Zero = max elbow bend upward
* Wavehand(5): 160- approximate max extension
* 60- approximate max retraction
* Head(9):
* 0-180 deg
* creephand = 2
*
* VarspeedServo is just like #Servo but you can use:
* myServo.attach (mainPin, ServoMin, ServoMax);
* myServo.slowmove (newpos, speed);
* 0 = full speed 1= slowest to range 255, but 127 was this guys fastest observed.
*
*/
#include <VarSpeedServo.h>
VarSpeedServo headservo;
VarSpeedServo elbowservo;
VarSpeedServo handservo;
int pos = 105; //set initial servo position
int Sensor = 7; //Input Pin
int LED = 13; // Led pin for Indication
int flg;
void setup() {
Serial.begin(9600);
headservo.attach(9); // syntax: myServo.attach (mainPin, ServoMin, ServoMax);
elbowservo.attach(3);
handservo.attach(5);
pinMode (Sensor, INPUT); //Define Pin as input
pinMode (LED, OUTPUT); //Led as OUTPUT
Serial.println("Waiting for motion");
}
void loop() {
int val = digitalRead(Sensor); //Read Pin as input
if((val > 0) && (flg==0))
{
digitalWrite(LED, HIGH);
Serial.println("Motion Detected");
flg = 1; headservo.slowmove(158,1);
}
if(val == 0)
{
digitalWrite(LED, LOW);
flg = 0; headservo.slowmove (77, 1);
}
delay(50);
}
Thanks for any help! **Also, my goal was to simplify servo speed adjustments in coding which I will use often. If anyone has an alternative library suggestion or method that would be great too.