Probaj i ovako. Ja ne koristim arduino ali treba da radi.
#define DESNO 1
#define LEVO 0
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 Vrti(unsigned int broj_koraka, unsigned char smer)
{
unsigned int i = 0;
if(smer == DESNO)
digitalWrite(dir, HIGH);
else
digitalWrite(dir, LOW);
delay(100);
while(i++ < broj_koraka)
{
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(10);
}
}
void loop()
{
setup();
if(digitalRead(buttonPin) == LOW) //functions based off of button pulling input pin LOW
{
Vrti(200, DESNO);
}
}
#define DESNO 1
#define LEVO 0
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 Vrti(unsigned int broj_koraka, unsigned char smer)
{
unsigned int i = 0;
if(smer == DESNO)
digitalWrite(dir, HIGH);
else
digitalWrite(dir, LOW);
delay(100);
while(i++ < broj_koraka)
{
digitalWrite(stp, HIGH);
delay(10);
digitalWrite(stp, LOW);
delay(10);
}
}
void loop()
{
setup();
if(digitalRead(buttonPin) == LOW) //functions based off of button pulling input pin LOW
{
Vrti(200, DESNO);
}
}