Created
August 23, 2019 16:00
-
-
Save samirsogay/43b87d7830d98a54a6bff6f994b9ff16 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
int bluePin = 2; //IN1 on the ULN2003 Board, BLUE end of the Blue/Yellow motor coil | |
int pinkPin = 3; //IN2 on the ULN2003 Board, PINK end of the Pink/Orange motor coil | |
int yellowPin = 4; //IN3 on the ULN2003 Board, YELLOW end of the Blue/Yellow motor coil | |
int orangePin = 5; //IN4 on the ULN2003 Board, ORANGE end of the Pink/Orange motor coil | |
//going up | |
//Keeps track of the current step. | |
//We'll use a zero based index. | |
int currentStep = 0; | |
void setup() { | |
// put your setup code here, to run once: | |
Serial.begin(9600); | |
pinMode(bluePin, OUTPUT); | |
pinMode(pinkPin, OUTPUT); | |
pinMode(yellowPin, OUTPUT); | |
pinMode(orangePin,OUTPUT); | |
digitalWrite(bluePin, LOW); | |
digitalWrite(pinkPin, LOW); | |
digitalWrite(yellowPin, LOW); | |
digitalWrite(orangePin, LOW); | |
} | |
void loop() { | |
//Comment out the Serial prints to speed things up | |
//Serial.print("Step: "); | |
//Serial.println(currentStep); | |
switch(currentStep){ | |
case 0: | |
digitalWrite(bluePin, HIGH); | |
digitalWrite(pinkPin, HIGH); | |
digitalWrite(yellowPin, LOW); | |
digitalWrite(orangePin, LOW); | |
break; | |
case 1: | |
digitalWrite(bluePin, LOW); | |
digitalWrite(pinkPin, HIGH); | |
digitalWrite(yellowPin, HIGH); | |
digitalWrite(orangePin, LOW); | |
break; | |
case 2: | |
digitalWrite(bluePin, LOW); | |
digitalWrite(pinkPin, LOW); | |
digitalWrite(yellowPin, HIGH); | |
digitalWrite(orangePin, HIGH); | |
break; | |
case 3: | |
digitalWrite(bluePin, HIGH); | |
digitalWrite(pinkPin, LOW); | |
digitalWrite(yellowPin, LOW); | |
digitalWrite(orangePin, HIGH); | |
break; | |
} | |
//CCW | |
//currentStep = (--currentStep >= 0) ? currentStep : 3; | |
//CW | |
currentStep = (++currentStep < 4) ? currentStep : 0; | |
//2000 microseconds, or 2 milliseconds seems to be | |
//about the shortest delay that is usable. Anything | |
//lower and the motor starts to freeze. | |
//delayMicroseconds(2250); | |
delay(15); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Hi, just uncomment line 61 and comment out line 64.