Stepper Motors Synth

by vincentpaulines in Circuits > Arduino

691 Views, 4 Favorites, 0 Comments

Stepper Motors Synth

Lacunosa Town on... Stepper Motors?
IMG_1220.jpg

Hellohello! Over the course of a month I worked on an instrument using stepper motors that connects to MIDI data. I have seen many of these making song covers on Youtube so I decided to make my own with an Arduino microcontroller. Before I talk about my own project, you should check out the Stepper Motor Synth project by Jonathan Kayne which I based my code around. He has also made a much bigger Synth with 32 motors using FPGA if want to look into that as well.


The stepper motors basically work by rotating at a certain frequency that matches a note frequency (you can find these online). From that, the vibrations from the motor create the wanted note. One problem with doing it this way is that a single motor can only produce one note at a time. You can offset this by having multiple motors play at the same time, though timing motors to play the way you want is difficult to do as code can only be read one line at a time with an Arduino. To do this, a non-blocking function is used via an array that holds note data for each motor (which corresponds to a different MIDI channel) that continually updates. To process MIDI data, the MIDI Arduino Library by FortySevenEffects is used. Doing it this way also has the added benefit that you do not have to input the songs in your Arduino code directly. Furthermore, I wanted this project to be not reliant on my computer to use so it all runs with a 12V power supply with a 9V voltage regulator to power the Arduino, though this is not necessary if you are okay with powering it with just connecting it to your computer via USB.

Supplies

There are many components I used for this project, but for a bare bones setup this is all that is required:

  1. Stepper Motors, specifically NEMA 17 ones (I used 6 motors, but minimum required for most songs is probably 4)
  2. Stepper Motor Drivers, I used A4988 drivers
  3. Arduino microcontroller, I used a Nano
  4. MIDI Female Jack
  5. A MIDI cable, I used a MIDI to USB cable that can connect to my computer to send MIDI data
  6. An Optocoupler
  7. 4.7k Ohm Resistor
  8. 220 Ohm Resistors
  9. A diode, I used 1N4148 ones I had on hand
  10. At least 100uF Capacitors, I used 220uF Capacitors
  11. 12V power supply
  12. If you're using the power supply I used, you will also need a cable to connect to the mains power. You can either buy one online or just cut a cable you have at home
  13. A DAW to create MIDI files for songs and output MIDI data
  14. Wires and Breadboards

If you want to use a voltage regulator to power the microcontroller then you will also need:

  1. 7V-9V Voltage Regulator, theoretically you could go higher as the Vin pin of the Arduino maxes out at 12V but you may risk burning your pin
  2. You can also get a heatsink for the voltage regulator but I found that this is most likely unnecessary
  3. 0.1uF capacitor
  4. 0.33uF capacitor, this is according to the datasheet, but I actually used a 0.47uF capacitor since I did not have a 0.33uF one and that worked as well

To make the setup nice I also used 3D printed components and zip-ties, but you can just have the motors by themselves as well.

If you want to use the same STL files I used, you will need M3 and M4 hardware as well. These are what I used:

  1. M3 x 8, to connect to the motors though you can probably get away with smaller or longer screws depending on the motor used
  2. M3 x 12
  3. M4 x 8
  4. I also used foam for damping and pads to make sure the vibrations do not cause the motors to move, but this is optional

MIDI Input Circuit

Screenshot 2026-01-05 at 2.28.24 PM.png

To input MIDI data into the microcontroller, MIDI data is outputted from my computer to the MIDI jack and then to the RX pin on the microcontroller. This has a chance to burn your pin however. Thus, an optocoupler is used in between. This essentially sends a signal in a circuit without the input and output being electrically connected. This is done by an LED and Photodetector in the component. A longer explanation of this circuit can be found here by Notes and Volts. A schematic of the circuit can be seen above where the 5V and GND come from the corresponding pins on the microcontroller.

Stepper Motor Circuit

Screenshot 2026-01-05 at 2.42.13 PM.png

To run the stepper motors, I used A4988 drivers. The motors are powered by a shared 12V power supply and the drivers are powered by the 5V microcontroller pin. Additionally, 220uF capacitors were placed across the motor power to protect it from LC voltage spikes which may damage the drivers. The DIR (which controls direction) and STEP (which controls the motor stepping) are connected to the digital I/O pins on the microcontroller. Theoretically you could also connect the DIR pins to the 5V or GND as direction does not matter for making music, which would free more I/O pins, but for a 6 motor setup this is unnecessary. Finally, I made the motors microstep at a resolution of eighth steps by connecting the MS1 and MS2 pins to the 5V line. This makes the stepper motors make cleaner sounds, but at the cost of being a little more quieter. Moreover, I suggest adjusting the current limiter to 0.9 - 1 A as I noticed that the drivers can get quite toasty. You can do this by adjusting the screw and measuring the voltage there. The formula for the voltage and current can be found on the A4988 driver datasheet. A schematic of a single driver can be seen above.

Arduino Power Circuit

Screenshot 2026-01-05 at 2.46.51 PM.png

The Arduino power circuit with the voltage regulator is very simple. The 12V power supply goes to the input and the 9V output is connected to the Vin pin and second GND pin on the microcontroller. Capacitors are also used at the input and output which are shown in the schematic above.

Entire Circuit

Screenshot 2026-01-05 at 2.47.52 PM.png
IMG_1219.jpg

The entire circuit can be seen above. Zip-ties were used to clean the circuit up. Overall five breadboards were used, but I think the MIDI input circuit, Arduino nano, and Arduino power circuit can be squeezed into one breadboard. Also, the stepper motor drivers can also be less spaced out as well.

Arduino Code

The Arduino code used can be found below. Also remember to have the MIDI Arduino library or else the code will not work.

3D Printed Components for the Motors

Screenshot 2026-01-05 at 3.14.05 PM.png
Screenshot 2026-01-05 at 3.14.28 PM.png
Screenshot 2026-01-05 at 3.16.35 PM.png
Screenshot 2026-01-05 at 3.16.00 PM.png

Next, I made 3D printed components for the motors to make the display nicer and have the motors all aligned. Additionally, there is a space to put foam as I noticed that damped the sounds in a really nice way while testing, though this is probably unnecessary in retrospect especially with microstepping enabled. Pads are placed at the bottom as to make sure that the motor vibrations do not cause movement of the motors. Furthermore, I printed out horns so that the rotation of the motors are more apparent. One of them I made as a disk to add a sticker which looks very cute. Right now the horns are black, but I want to reprint them in a different color so that stand out more. The STL files are below.

Outputting MIDI Data

Finally, the last part is to send MIDI data for the stepper motors to actually play. For the MIDI output, I used MuseScore 3 as it is much simpler to use than other software and is free. Make sure to get MuseScore 3 and not 4 as you cannot change the MIDI channel of the instrument in that version. For making MIDI files, you can find plenty music sheets online to use. In the MIDI file itself, make sure each instrument is at a separate MIDI channel corresponding to each motor and that only one music note is being played at a single moment. Example MIDI files can be found in this drive folder (Unfortunately Instructables does not support MIDI files :c). There is one folder that works with 6 motors, and another that works with 4 motors.

Finished Woohoo!

Stepper Motors do the Caramelldansen

And that's it! This was a very fun project to work and learned a lot (particularly with electronic components). In the end I am quite happy with the result, though there are few improvements I would like to make. One aspect I noticed is that the high pitched notes sound a little awkward, so maybe some tuning is needed to change the frequency the motors play at with those notes. Additionally, though I could technically carry it around for display, the wiring would make that awkward and take up too much space. So what I would like to do is make a shield for the nano that can be put in an enclosure. Finally, for some songs, not every motor is needed and when a motor is idle, there is a high pitched sound that you can hear (this is essentially the sound of the motor trying to stay at its current position). This can be circumvented by just having multiple motors play the same notes, but you can also do this by having switches for each of the motor's power. I would like to implement these changes in the future, though for it currently is I am very satisfied with the result. If you decide to make your own stepper motor instrument, please let me know!