Pages: [1]   Go Down
Author Topic: sketch error ?? help  (Read 467 times)
0 Members and 1 Guest are viewing this topic.
uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

have you downloaded the AccelStepper library?
Logged

~Tom~

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

no ????
Logged

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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
Logged

~Tom~

uk
Offline Offline
Jr. Member
**
Karma: 0
Posts: 61
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

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

Leeds, UK
Offline Offline
Edison Member
*
Karma: 78
Posts: 1719
Once the magic blue smoke is released, it won't go back in!
View Profile
WWW
 Bigger Bigger  Smaller Smaller  Reset Reset

http://www.ladyada.net/library/arduino/libraries.html
Logged

~Tom~

Pages: [1]   Go Up
Jump to: