Permalink
Browse files

initial commit

turning the motor after plugging in, no wifi, no webserver yet
  • Loading branch information...
PaulPetring committed Jun 30, 2016
1 parent e68ad2e commit 3d93ef6a5eeeb117c79edfc5a6a29e18e70817e9
Showing with 50 additions and 0 deletions.
  1. +50 −0 simple.ino
@@ -0,0 +1,50 @@
int stepdelay=5;

int in1 = 16;
int in2 = 14;
int in3 = 12;
int in4 = 13;

void FWD(int steps)
{ for (int i=0; i <= steps; i++){
digitalWrite(in1, LOW); digitalWrite(in4, HIGH); delay(stepdelay);
digitalWrite(in3, LOW); digitalWrite(in2, HIGH); delay(stepdelay);
digitalWrite(in4, LOW); digitalWrite(in1, HIGH); delay(stepdelay);
digitalWrite(in2,LOW); digitalWrite(in3, HIGH); delay(stepdelay);
}
}

void BACK(int steps)
{ for (int i=0; i <= steps; i++){
digitalWrite(in2,LOW); digitalWrite(in3, HIGH); delay(stepdelay);
digitalWrite(in4, LOW); digitalWrite(in1, HIGH); delay(stepdelay);
digitalWrite(in3, LOW); digitalWrite(in2, HIGH); delay(stepdelay);
digitalWrite(in1, LOW); digitalWrite(in4, HIGH); delay(stepdelay);
}
}

void STOP()
{
digitalWrite(in1,LOW);
digitalWrite(in2,LOW);
digitalWrite(in3,LOW);
digitalWrite(in4,LOW);
}
void setup()
{
pinMode(in1, OUTPUT);
pinMode(in2, OUTPUT);
pinMode(in3, OUTPUT);
pinMode(in4, OUTPUT);
}

void loop()
{
FWD(720);
delay(500);
BACK(720);
delay(500);
STOP();
delay(500);
}

0 comments on commit 3d93ef6

Please sign in to comment.