defining constants in seperate file...

I have a file _init.pde:

/****************************************************************************************
* digital i/o pin assignment
*
* this uses the undocumented feature of Arduino - pins 14-19 correspond to analog 0-5
****************************************************************************************/

//cartesian bot pins
#define X_STEP_PIN 2
#define X_DIR_PIN 3
#define X_MIN_PIN 4
#define X_MAX_PIN 9
#define X_ENABLE_PIN 15

then I would use this in StepperTest:

/*
 * Stepper
 *
 *
 * http://www.arduino.cc/
 */


int dirPin = 9;
int delayTime = 250;
int ledPin = 13;

int input;

void setup()                    // run once, when the sketch starts
{
  pinMode(X_STEP_PIN, OUTPUT);      // sets the digital pin as output
  pinMode(dirPin, OUTPUT);  
  pinMode(ledPin, OUTPUT); 
  digitalWrite(dirPin, HIGH);
  
  
  Serial.begin(9600);
  Serial.println("hei");
}

void loop()                     // run over and over again
{
  input = Serial.read();
  if(Serial.available()>0){
    Serial.println("duude");
    if(input==65){
       digitalWrite(dirPin, HIGH);
       digitalWrite(ledPin, HIGH);
    }
    if(input==66){
       digitalWrite(dirPin, LOW);
       digitalWrite(ledPin, LOW);
    }
    
    Serial.println(input);
  }
  
  digitalWrite(stepPin, HIGH);   // sets the step pin high
  delayMicroseconds(delayTime);              // waits for a given time
  digitalWrite(stepPin, LOW);    // sets the LED off
  delayMicroseconds(delayTime*1.5);                  // waits for a given time
}

then i am getting this error:

In function 'void setup()':
error: 'X_STEP_PIN' was not declared in this scope In function 'void loop()':

What am I doing wrong?

I would also like to modify the code to use the arrow keypad to test the stepper. Up= increase speed, Down = decrease speed, Left= turn clockwise , right = turn anti clockwise.

I guess this would be a nice sketch for people that just want to test their stepper motor...

Maybe later also add The following input: G0 X15 Which can help u calibrating the movement of the stepper.

The idea is to have a simple sketch to just ensure that the stepper motor works the way its suppose to, and only for one axis,

than later u can use the reprap code..

Any comments??

How is the sketch supposed to know about the file with the definitions in it? Do you have the mind reading attachment powered up and configured correctly?

with the pde and .h in the same place, add:

#include <filename.h>

to the top of the pde :slight_smile:

still get the same error....

Rename _init.pde to _init.h (this may not be strictly necessary but if the file only contains defines for the main sketch then .h is a more appropriate name).

In the main sketch, add:
#include "_init.h"

To get the sketch to compile, you need to modify the sketch file or header so that the names match, the sketch uses:
stepPin
but the header defines:
X_STEP_PIN