Hi thanks allready for all the tips and hints.
This is what I've got, but there is something wrong in the code because it won't work.
const int stepPin = 3;
const int dirPin = 4;
int relpin = 12;
const int stepsPerRevolution = 200;
boolean running = false;
void setup() {
pinMode(stepPin,OUTPUT);
pinMode(dirPin,OUTPUT);
pinMode(relpin, INPUT);
digitalWrite (relpin, LOW);
Serial.begin(9600);
}
void loop()
{
if (digitalRead(relpin)==HIGH)
running = !running;
if (running == !running)
{
digitalWrite(dirPin,HIGH);
for(int x = 0; x < 200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
else
digitalWrite(dirPin,LOW);
for(int x = 0; x < 200; x++)
{
digitalWrite(stepPin,HIGH);
delayMicroseconds(500);
digitalWrite(stepPin,LOW);
delayMicroseconds(500);
}
}
Can someone give me another help?