Public projects 1

Arduino MIDI Stepper Synth

Project tutorial by Jonathan Kayne

  • 33,330 views
  • 30 comments
  • 74 respects

Toolbox 1


Respected projects 0

 Jonathan Kayne hasn't respected any projects yet.
  • Arduino MIDI Stepper Synth 2 months ago

    #define stepPin 2
    #define dirPin 5
    #define enPin 8
    // DEFINE THE OTHER STEP, DIR, and EN pins
    const int Time_1 = 5000;
    const int Time_2 = 5000;
    const int step_1 = 200;
    const int step_2 = 200;

    void setup() {
    pinMode(stepPin, OUTPUT);
    pinMode(dirPin, OUTPUT);
    pinMode(enPin, OUTPUT);
    digitalWrite(enPin, LOW);
    //DUPLICATE THE ABOVE 4 LINES FOR EACH MOTOR

    }

    void loop() {
    digitalWrite(dirPin, HIGH);
    // DUPLICATE FOR THE OTHER MOTORS

    for (int i = 0; i < step_1; i++)
    {
    digitalWrite(stepPin, HIGH);
    // DUPLICATE FOR THE OTHER MOTORS
    //delayMicroseconds(Time_1);
    digitalWrite(stepPin, LOW);
    // DUPLICATE FOR THE OTHER MOTORS
    delayMicroseconds(Time_1);
    }

    delayMicroseconds(2000);

    digitalWrite(dirPin, LOW);
    // DUPLICATE FOR THE OTHER MOTORS
    for (int i = 0; i < step_2; i++)
    {
    digitalWrite(stepPin, HIGH);
    // DUPLICATE FOR THE OTHER MOTORS
    //delayMicroseconds(Time_2);
    digitalWrite(stepPin, LOW);
    // DUPLICATE FOR THE OTHER MOTORS
    delayMicroseconds(Time_2);
    }

    digitalWrite(enPin, HIGH);
    // DUPLICATE FOR THE OTHER MOTORS
    while(1); //stop loop

    }

    Hope that helps!
    -Jonathan

  • Arduino MIDI Stepper Synth 2 months ago

    Hi Carl,
    The A4988 has two pins that get the power for the motors (VMOT and GND). You would want to make sure each driver gets the 12V that way. If you look up A4988 wiring you should see how to wire everything.
    The Test Stepper code simply moves the stepper a certain amount clockwise then counterclockwise. Basically, when you make the step pin on the A4988 driver go from low to high, the stepper motor will move one "step". In the default setting this is exactly 1/200th of a revolution or 1.8 degrees. If you want to make it work for more than one motor simultaneously, define more step and direction pins and then duplicate the digitalWrite() for each of the step pins. I put some comments to show where to modify the code below.
    It might be a good idea to check out this video as it will give you a better understanding of stepper motors: https://www.youtube.com/watch?v=5CmjB4WF5XA

  • Arduino MIDI Stepper Synth 2 months ago

    The whine occurs when the stepper motors are enabled. You can modify the code so that the enable pin is pulled high after a certain amount of time has elapsed. I was still learning Arduino code when I did the project so I didn't implement it in this version. Easiest way right now is to press the reset button whenever you want the whine to stop

Add projectSign up / Login