Working Principle

Electronics

We used Arduino Mega 2560 microcontroller to control our stepper motors and LED lights. Since we had to control 12 stepper motors individually, we connected 12 A4988 stepper motor drivers 3 CNC shields (4 stepper drivers each) which are in turn connected to our Arduino mega board. The 3 CNC shields were wired together so that we can power the whole set-up with 1 power source. The LED lights used are called a WS2812 led strip which was also powered by the Arduino mega board.

 

Software

To control the stepper motors, we used the BasicStepperDriver library and the FastLED library to power our LED lights. The motors were initialized at 200 steps per revolution and we settled on an RPM of 100 for the motors to minimize the delay when strumming the strings. Microsteps were set to 1.

Firstly, the motors were homed to their correct positions before the song starts. This was done in code by first rotating all the motors to contact the physical stoppers we built into our frame. From the stopper positions, the motor arms were rotated to their correct positions from which they are within range of strumming the strings.

Next, to play the songs, a function is written for each motor. The function is binary in nature, either rotating the motor clockwise or anticlockwise. This is such that the strumming motion can be achieved. To play the songs, each function is called, corresponding to each note that has to be played. A delay is added between the functions to play the song according to the tempo.

Since our songs are very long and can consist of hundreds of notes being played, we created a python script to read MIDI files and turn them into instructions to be inserted into our Arduino code. We download the MIDI files of the songs we want to play and run them through the python code which automatically turns into a text file with the commands in Arduino format which we copy and paste into our Arduino code.

Finally, our LED code is embedded into each function such that an LED lights up each time a note is played.

Our Python script

Skip to toolbar