/* Simple Stepper Motor Control Exaple Code * * by Dejan Nedelkovski, www.HowToMechatronics.com * */ // defines pins numbers const int stepPin = 3; const int dirPin = 4; float pH; int steps = 0; void setup() { // Sets the two pins as Outputs Serial.begin(9600); pinMode(stepPin,OUTPUT); pinMode(dirPin,OUTPUT); } void loop() { digitalWrite(dirPin,HIGH); // Enables the motor to move in a particular direction // 200 pulses for one full cycle rotation 1.8 degree step steps = 50; //test value Serial.println(steps); for(int x = 0; x < steps; x++) { digitalWrite(stepPin,HIGH); delayMicroseconds(2500); digitalWrite(stepPin,LOW); delayMicroseconds(2500); } delay(2000); // Two second delay }