//STEPPER MOTOR CODE IS AS UNDER if You are coming from our YouTube Channel : Sonu Model Makers #StepperMotorCode #StepperMotorArduinoCode
//original source is http://www.geeetech.com/wiki/index.php/Stepper_Motor_5V_4-Phase_5-Wire_%26_ULN2003_Driver_Board_for_Arduino // Update by Ahmad Shamshiri for RoboJax.com // Published on March 27, 2017 in Aajx, ON, Canada. int Pin1 = 10; int Pin2 = 11; int Pin3 = 12; int Pin4 = 13; int _step = 0; boolean dir = true;// false=clockwise, true=counter clockwise int count=0; void setup() { pinMode(Pin1, OUTPUT); pinMode(Pin2, OUTPUT); pinMode(Pin3, OUTPUT); pinMode(Pin4, OUTPUT); } void loop() { switch(_step){ case 0: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, HIGH); break; case 1: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, HIGH); digitalWrite(Pin4, HIGH); break; case 2: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, HIGH); digitalWrite(Pin4, LOW); break; case 3: digitalWrite(Pin1, LOW); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, HIGH); digitalWrite(Pin4, LOW); break; case 4: digitalWrite(Pin1, LOW); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; case 5: digitalWrite(Pin1, HIGH); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; case 6: digitalWrite(Pin1, HIGH); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; case 7: digitalWrite(Pin1, HIGH); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, HIGH); break; default: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; } if(dir){ _step++; }else{ _step--; } if(_step>7){ _step=0; } if(_step<0){ _step=7; } delay(1); }
//original source is http://www.geeetech.com/wiki/index.php/Stepper_Motor_5V_4-Phase_5-Wire_%26_ULN2003_Driver_Board_for_Arduino // Update by Ahmad Shamshiri for RoboJax.com // Published on March 27, 2017 in Aajx, ON, Canada. int Pin1 = 10; int Pin2 = 11; int Pin3 = 12; int Pin4 = 13; int _step = 0; boolean dir = true;// false=clockwise, true=counter clockwise int count=0; void setup() { pinMode(Pin1, OUTPUT); pinMode(Pin2, OUTPUT); pinMode(Pin3, OUTPUT); pinMode(Pin4, OUTPUT); } void loop() { switch(_step){ case 0: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, HIGH); break; case 1: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, HIGH); digitalWrite(Pin4, HIGH); break; case 2: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, HIGH); digitalWrite(Pin4, LOW); break; case 3: digitalWrite(Pin1, LOW); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, HIGH); digitalWrite(Pin4, LOW); break; case 4: digitalWrite(Pin1, LOW); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; case 5: digitalWrite(Pin1, HIGH); digitalWrite(Pin2, HIGH); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; case 6: digitalWrite(Pin1, HIGH); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; case 7: digitalWrite(Pin1, HIGH); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, HIGH); break; default: digitalWrite(Pin1, LOW); digitalWrite(Pin2, LOW); digitalWrite(Pin3, LOW); digitalWrite(Pin4, LOW); break; } if(dir){ _step++; }else{ _step--; } if(_step>7){ _step=0; } if(_step<0){ _step=7; } delay(1); }
No comments:
Post a Comment