/* The BYJ-series are unipolar stepper motors. In this project the stepper motor is a 20BYJ46. The driver is a mini-ULN2003. Verify the rated voltage. Use a 5V version when using the Arduino power supply. Check the current with the formula: U=IxR. The 5V version of the 20BYJ46 has a resistance of 60ohm. The current is then I=U/R=5/60=0.08A. The Arduino is not able to supply enough current at the digital pins to power a stepper motor directly. To protect the Arduino a driver is used. A driver reads at the input pins the status of the digital pins of the Arduino and writes to the output pins. When the input pin 1B is “High” the power supplied to the driver is routed to pin VCC(+) and 1C(-). Wires of the stepper motor to the stepper driver (motor and driver are provided with matching socket and plug) Arduino Stepper Stepper Stepper driver in driver out moto wire 5V Vcc Vcc Red Gnd Gnd Pin 11 1B 1C Orange Pin 10 2B 2C Yellow Pin 9 3B 3C Purple Pin 8 4B 4C Blue To rotate the stepper motor the Arduino must make a digital pin “High”, other pins must be “LOW” when the rotation of the stepper motor is done the Arduino must make the next pin “HIGH”, other pins must be “LOW” and so on. When this is repeated the stepper motor starts to rotate. Motor Motor Motor Motor Arduino 12 o’ clock 3 o’ clock 6 o’ clock 9 o’clock Pin 11 HIGH LOW LOW LOW Pin 10 LOW HIGH LOW LOW Pin 9 LOW LOW HIGH LOW Pin 8 LOW LOW LOW HIGH */ /* 20170605 Changelog SBE - Changed delaytime to 5, at delaytime 2 the engine stalls */ int motorPin1 = 8; int motorPin2 = 9; int motorPin3 = 10; int motorPin4 = 11; int delayTime = 5; //At delaytime 2 it stops turning void setup() { pinMode(motorPin1, OUTPUT); pinMode(motorPin2, OUTPUT); pinMode(motorPin3, OUTPUT); pinMode(motorPin4, OUTPUT); } void loop() { digitalWrite(motorPin1, HIGH); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); delay(delayTime); digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, HIGH); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, LOW); delay(delayTime); digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, HIGH); digitalWrite(motorPin4, LOW); delay(delayTime); digitalWrite(motorPin1, LOW); digitalWrite(motorPin2, LOW); digitalWrite(motorPin3, LOW); digitalWrite(motorPin4, HIGH); delay(delayTime); }