Format HullPixelbot Dance code

This commit is contained in:
Starbeamrainbowlabs 2017-07-22 15:11:00 +01:00
parent fd6fa2fe44
commit 2fdcecc6c6
1 changed files with 25 additions and 26 deletions

View File

@ -5,15 +5,15 @@
//////////////////////////////////////////////// ////////////////////////////////////////////////
//declare variables for the motor pins //declare variables for the motor pins
int rmotorPin1 = 16; // Purple - 28BYJ48 pin 1 const int rmotorPin1 = 16; // Purple - 28BYJ48 pin 1
int rmotorPin2 = 5; // Grey - 28BYJ48 pin 2 const int rmotorPin2 = 5; // Grey - 28BYJ48 pin 2
int rmotorPin3 = 4; // White - 28BYJ48 pin 3 const int rmotorPin3 = 4; // White - 28BYJ48 pin 3
int rmotorPin4 = 0; // Black - 28BYJ48 pin 4 const int rmotorPin4 = 0; // Black - 28BYJ48 pin 4
int lmotorPin1 = 2; // Yellow - 28BYJ48 pin 1 const int lmotorPin1 = 2; // Yellow - 28BYJ48 pin 1
int lmotorPin2 = 14; // Orange - 28BYJ48 pin 2 const int lmotorPin2 = 14; // Orange - 28BYJ48 pin 2
int lmotorPin3 = 12; // Red - 28BYJ48 pin 3 const int lmotorPin3 = 12; // Red - 28BYJ48 pin 3
int lmotorPin4 = 13; // Brown - 28BYJ48 pin 4 const int lmotorPin4 = 13; // Brown - 28BYJ48 pin 4
int motorSpeed = 1200; //variable to set stepper speed int motorSpeed = 1200; //variable to set stepper speed
@ -62,30 +62,29 @@ void moveStep()
{ {
for(int i = 0; i < 8; i++) for(int i = 0; i < 8; i++)
{ {
switch(moveState) switch(moveState)
{ {
case STOP: case STOP:
return; return;
case FORWARD: case FORWARD:
setOutputDir(i,7-i); setOutputDir(i,7-i);
break; break;
case BACK: case BACK:
setOutputDir(7-i,i); setOutputDir(7-i,i);
break; break;
case LEFT: case LEFT:
setOutputDir(7-i,7-i); setOutputDir(7-i,7-i);
break; break;
case RIGHT: case RIGHT:
setOutputDir(i,i); setOutputDir(i,i);
break; break;
} }
delayMicroseconds(motorSpeed); delayMicroseconds(motorSpeed);
} }
} }
void setOutputDir(int leftOut, int rightOut) void setOutputDir(int leftOut, int rightOut)
{ {
digitalWrite(lmotorPin1, bitRead(lookup[leftOut], 0)); digitalWrite(lmotorPin1, bitRead(lookup[leftOut], 0));
digitalWrite(lmotorPin2, bitRead(lookup[leftOut], 1)); digitalWrite(lmotorPin2, bitRead(lookup[leftOut], 1));
digitalWrite(lmotorPin3, bitRead(lookup[leftOut], 2)); digitalWrite(lmotorPin3, bitRead(lookup[leftOut], 2));