static int step = 7;
static int dir = 6;
static int knof = 8;
static int knof1 = 9;
void setup() {
// put your setup code here, to run once:
Serial.begin(9600);
pinMode(step, OUTPUT);
pinMode(dir, OUTPUT);
pinMode(knof, INPUT);
pinMode(knof1, INPUT);
}
void loop() {
// put your main code here, to run repeatedly:
int zasuk =113;
Serial.print("Knof ");
Serial.println(digitalRead(knof));
Serial.print("Knof1 ");
Serial.println(digitalRead(knof1));
if(digitalRead(knof)==1)
{
digitalWrite(dir, HIGH);//določimo smer vrtenja
// za bumbarje
digitalWrite(step, HIGH);//
delayMicroseconds(10);//en pulz
digitalWrite(step, LOW);//
delayMicroseconds(10);//1x
digitalWrite(step, HIGH);//
delayMicroseconds(10);//en pulz
digitalWrite(step, LOW);//
delayMicroseconds(10);//2x
digitalWrite(step, HIGH);//
delayMicroseconds(10);//en pulz
digitalWrite(step, LOW);//
//3x
delay(500);//cajt izpustit tipko
}
if(digitalRead(knof1)==1)
{
digitalWrite(dir, LOW);//določimo smer vrtenja
// za ta pametne
//funkcija ki proži korak 113x
for(int i = 0; i < zasuk; i++)
{
korak();
delay(10);
}
//drugi nacin
//korak();
//korak();
//korak();
delay(500);//cajt izpustit tipko
}
}
void korak()//kle je mn besedila
{
digitalWrite(step, HIGH);
delayMicroseconds(10);
digitalWrite(step, LOW);
delayMicroseconds(10);
}