Go Down

Topic: sketch error ?? help (Read 537 times) previous topic - next topic

markthespark

i got this sketch off the net it shows the stepper working but when i upload the sketch i get errors
why

// accellsteppertest.ino
// Runs one stepper forwards and backwards, accelerating and decelerating
// at the limits. Derived from example code by Mike McCauley
// Set for 28BYJ-48 stepper

#include <AccelStepper.h>

#define FULLSTEP 4
#define HALFSTEP 8

//declare variables for the motor pins
int motorPin1 = 8;   // Blue   - 28BYJ48 pin 1
int motorPin2 = 9;   // Pink   - 28BYJ48 pin 2
int motorPin3 = 10;   // Yellow - 28BYJ48 pin 3
int motorPin4 = 11;   // Orange - 28BYJ48 pin 4
                       // Red    - 28BYJ48 pin 5 (VCC)

// The sequence 1-3-2-4 required for proper sequencing of 28BYJ48
AccelStepper stepper2(HALFSTEP, motorPin1, motorPin3, motorPin2, motorPin4);

void setup()
{    
 stepper2.setMaxSpeed(1000.0);
 stepper2.setAcceleration(50.0);
 stepper2.setSpeed(200);
 stepper2.moveTo(2048);
}

void loop()
{
 //Change direction at the limits
 if (stepper2.distanceToGo() == 0) {
   stepper2.moveTo(-stepper2.currentPosition());
 }
 stepper2.run();
}




errors are
sketch_sep18c:18: error: 'AccelStepper' does not name a type
sketch_sep18c.cpp: In function 'void setup()':
sketch_sep18c:22: error: 'stepper2' was not declared in this scope
sketch_sep18c.cpp: In function 'void loop()':
sketch_sep18c:31: error: 'stepper2' was not declared in this scope
sketch_sep18c:34: error: 'stepper2' was

thanks marko

Tom Carpenter

have you downloaded the AccelStepper library?
~Tom~


Tom Carpenter

Well theres your problem then. Your sketch can't use code that you haven't provided it.
Notice this line:
#include <AccelStepper.h> 

The library can be found here:
https://github.com/adafruit/AccelStepper
~Tom~

markthespark

ahhhh got it now but where do i put the <AccelStepper.h> ?

Tom Carpenter

http://www.ladyada.net/library/arduino/libraries.html
~Tom~

Go Up