My first attempt to write some arduino code for a simple stepper motor driver. This is used in combination with the L298 boards available from E bay for so little money that building makes no sense.
Only 2 buttons were required to mover either right or left. A very simple speed control is used with a switch and 2 resistors. One could use a pot-meter instead to have it fully variable.
// Stepper motor with 4 buttons for controlling my EME dish with 2 stepper motors. // It has a very simple speed control // And a powersaving so that it doesnot consume too much current when not in use// 18 september 2013 Geert Stams PA3CSG http://pa3csg.hoeplakee.nl#include <Stepper.h>const int stepsPerRevolution = 48; // change this to fit the number of steps per revolution// for your motor#define CW 2 //CW switch on digital pin 2#define CCW 3 //CCW switch on digital pin 3#define UP 8 //UP switch on digital pin 8#define DWN 13 //DWN switch on digital pin 13// create an instance of the stepper class, specifying// the number of steps of the motor and the pins it's// attached toStepper stepperA(stepsPerRevolution, 9, 10, 11, 12);Stepper stepperE(stepsPerRevolution, 4, 5, 6, 7);int stepCount = 0; // number of steps the motor has takenvoid setup(){ pinMode(A0, INPUT); pinMode(CW, INPUT); pinMode(CCW, INPUT); pinMode(UP, INPUT); pinMode(DWN, INPUT); digitalWrite(CW, 1); //pullup high digitalWrite(CCW, 1); //pullup high digitalWrite(UP, 1); //pullup high digitalWrite(DWN, 1); //pullup high}void loop(){ delay(2); int sensorReading = analogRead(A0); // read the sensor value: int motorSpeed = map(sensorReading, 0, 1023, 0, 100); // map it to a range from 0 to 100 // the following sets the motor speed: if (motorSpeed > 0) stepperA.setSpeed(motorSpeed); //set motorspeed for Az motor stepperE.setSpeed(motorSpeed); //set motorspeed for EL motor if (!digitalRead(CW)) stepperA.step(10); //reads button CW and moves stepperA 10 stepsdelay(10);if (!digitalRead(CCW)) stepperA.step(-10); //reads button CCW and moves stepperA 10 stepsdelay(10);digitalWrite(9, LOW); //sets pin# to LOW for current savingdigitalWrite(10, LOW); //sets pin# to LOW for current savingdigitalWrite(11, LOW); //sets pin# to LOW for current savingdigitalWrite(12, LOW); //sets pin# to LOW for current savingif (!digitalRead(UP)) stepperE.step(10); //reads button UP and moves stepperE 10 stepsdelay(10);if (!digitalRead(DWN)) stepperE.step(-10); //reads button DWN and moves stepperE 10 stepsdelay(10);digitalWrite(4, LOW); //sets pin# to LOW for current savingdigitalWrite(5, LOW); //sets pin# to LOW for current savingdigitalWrite(6, LOW); //sets pin# to LOW for current savingdigitalWrite(7, LOW); //sets pin# to LOW for current saving}