/* Simple Stepper Motor Control Exaple Code * * by Dejan Nedelkovski, www.HowToMechatronics.com * * modified by Megumi Iwata on 13.04.2018 */ // defines pins numbers const int stepPin = 2; const int dirPin = 3; const int ledPin = 7; void setup() { // Sets the two pins as Outputs pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); pinMode(ledPin, OUTPUT); } void loop() { digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction // Makes 200 pulses for making one full cycle rotation for(int x = 0; x < 200; x++) { digitalWrite(stepPin,HIGH); digitalWrite(ledPin, HIGH); delay(30); digitalWrite(stepPin,LOW); digitalWrite(ledPin, LOW); delay(30); } }