Browse Source

Format HullPixelbot Dance code

master
Starbeamrainbowlabs 4 years ago
parent
commit
2fdcecc6c6
  1. 51
      Examples/HullPixelBotDance/HullPixelBotDance.ino

51
Examples/HullPixelBotDance/HullPixelBotDance.ino

@ -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…
Cancel
Save