10-06-2016, 10:11 PM
Evo kod ,pokusavam al dzaba ...
int stp = 5; //connect pin 11 to step
int dir = 2; // connect pin 10 to dir
int buttonPin = 11;
int a = 0;
void setup()
{
pinMode(buttonPin, INPUT_PULLUP);
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
}
void loop()
{
if(digitalRead(buttonPin) == LOW) //functions based off of button pulling input pin LOW
{
if (a < 200) //sweep 200 step in dir 1
{
a++;
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(10);
}
}
}
int stp = 5; //connect pin 11 to step
int dir = 2; // connect pin 10 to dir
int buttonPin = 11;
int a = 0;
void setup()
{
pinMode(buttonPin, INPUT_PULLUP);
pinMode(stp, OUTPUT);
pinMode(dir, OUTPUT);
}
void loop()
{
if(digitalRead(buttonPin) == LOW) //functions based off of button pulling input pin LOW
{
if (a < 200) //sweep 200 step in dir 1
{
a++;
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(10);
}
}
}