I'm having an issue that I can't seem to find the answer for.
I am attempting to use Guy Carpenter's SwitecX25 library to run a stepper motor, eventually a couple, but crawl, then walk... GitHub - clearwater/SwitecX25: Arduino library for Switec X25.168 and friends
I installed the library using the guide here on the arduino.cc site. http://arduino.cc/en/Guide/Libraries
I tried installing the SwitecX25.cpp and .h files inside a folder called SwitecX25, (Location: My Documents/Arduino/libraries/SwitecX25) but that gave me some errors, such as: error: stray '\302' in program, which seems to be saying that there is a problem with the included libraries, from what I have been able to find out. I seem to have been able to get rid of these errors by installing the SwitecX25.cpp and .h files just in the My Documents/Arduino/libraries folder.
Now I am getting these errors:
This report would have more information with
"Show verbose output during compilation"
enabled in File > Preferences.
Arduino: 1.0.4 (Windows 7), Board: "Arduino Uno"
sketch_may15a:23: error: 'SwitecX25' does not name a type
sketch_may15a.ino: In function 'void setup()':
sketch_may15a:28: error: 'motor1' was not declared in this scope
sketch_may15a.ino: In function 'void loop()':
sketch_may15a:42: error: 'motor1' was not declared in this scope
The full code I am using is straight from the Github examples.
//----------------------------------------------------------------------
// https://github.com/clearwater/SwitecX25
//
// This is an example of using the SwitchX25 library.
// It zero's the motor, sets the position to mid-range
// and waits for serial input to indicate new motor positions.
//
// Open the serial monitor and try entering values
// between 0 and 944.
//
// Note that the maximum speed of the motor will be determined
// by how frequently you call update(). If you put a big slow
// serial.println() call in the loop below, the motor will move
// very slowly!
//----------------------------------------------------------------------
#include <SwitecX25.h>
// standard X25.168 range 315 degrees at 1/3 degree steps
#define STEPS (315*3)
// For motors connected to pins 3,4,5,6
SwitecX25 motor1(STEPS,4,5,6,7);
void setup(void)
{
// run the motor against the stops
motor1.zero();
// start moving towards the center of the range
motor1.setPosition(STEPS/2);
Serial.begin(9600);
Serial.print("Enter a step position from 0 through ");
Serial.print(STEPS-1);
Serial.println(".");
}
void loop(void)
{
static int nextPos = 0;
// the motor only moves when you call update
motor1.update();
if (Serial.available()) {
char c = Serial.read();
if (c==10 || c==13) {
motor1.setPosition(nextPos);
nextPos = 0;
} else if (c>='0' && c<='9') {
nextPos = 10*nextPos + (c-'0');
}
}
}
Through some research I found this thread: Basic include questions - Programming Questions - Arduino Forum, that if I read that correctly, the #include <SwitecX25.h> must be at the top of the SwitecX25.cpp file as well as my sketch.
Looking at the github page for the SwitecX25.cpp file the #include <SwitecX25.h> is in the file.
I am assuming at this point that once I can get rid of the Does not name a type error, the motor1 not declared errors will also disappear.
What do I need to do to get this to work?
Thanks