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