Skip to content

Stepper Motor Music [on hold]

Time to report in with a fun little project (sort of). I saw this some time ago:

It’s very cool, and I enjoyed it immensely so because I am not very musically inclined, however much I’d like to be. There is almost a…genre of this kind of music, and it’s a lot of fun to listen and watch:

It should be noted the creator of the first video also wrote the score. This seems a great hassle to me, so I wanted this to be able to be supplied an already created score. There isn’t a whole lot of detail about the project, so I set out to recreate the project, which I thought would be a fun project to occupy me for a few days this summer, a week tops. For the record I started this about a month ago, and it still remains unfinished :[ due to a combination of some missing resources, and time (seriously, I was looking forward to playing so many videogame melodies). It’s sadly gathering dust right now and I’ve to pack it away for the moment, but before I do, I’m going to write down all my thoughts about it, so that I, and even anybody else, can hopefully finish it.

2014-07-25 22.23.26(the current state of the project)

So let’s get into it:

What you’ll need:

– Stepper motors, this is your “instrument”. The ones pictured above are SM42BYG011 and two SY35ST28. Simply because I had them on hand.

– Drivers. The ones used above are all DRV8825’s ( The datasheet also suggests putting some decoupling capacitors across the power source (at least 47uF)

– An MCU of your choice. The creator of the video from which I am drawing inspiration from is using an Arduino, but I decided to use an MSP430 launchpad, simply to double this as an exercise for learning how to program MSP430s, and that I had one lying around.

How it works:

– MIDI: (ripped straight from wikipedia) short for Musical Instrument Digital Interface, is a technical standard that describes a protocol, digital interfaceand connectors and allows a wide variety of electronic musical instruments, computers and other related devices to connect and communicate with one another.[1]

A MIDI device is essentially what we’re creating. We’re going to start with a .mid file containing music that we’d like to play, and decode it’s information to get which note to play, for how long, and which channel (instrument, steppers in this case). Another reason this project looked so attractive is because I knew this to be done already, thanks to miditones created by Len Shustek: His code takes a .mid file, and generates an array of integers that will specify the start of a particular note on any one of up to 8 channels, the end of that note, and any delays that needs to be implemented inbetween. The specifiers are explained in the source code. Here’s what I get when I run it on Daft Punk’s Get Lucky (gotten from here

char score[] = {
0,50, 0x90,31, 1,194, 0x80, 0x90,31, 1,244, 0x80, 0x90,31, 1,244, 0x80, 0x90,31, 1,244,
0x80, 0x90,50, 0x91,66, 0x92,62, 0x93,59, 0x94,35, 0x95,35, 0,26, 0x80, 0,98, 0x90,50, 0,26, ...

So this says to 1) delay for 50ms 2) start playing note 31* on channel 0 3) delay for 194ms 4) stop playing on channel 0…and so on. As the most musically challenged person the planet, it couldn’t be clearer if it was spelled out for me.

*Various charts of how midi notes are commonly corresponded to musical frequencies are available, ex:

– The steppers: if you have no knowledge of stepper motor operation…well it actually won’t hurt you very much if you do buy the driver listed above, or a similar one (but you should still take a moment to read up on it, it’s fascinating). What you need to know is that stepper motors move in series of “steps”. This mechanical motion is audible, so you can “play music” by making the motor move a certain number of steps per second. For example, if I excite the motor 261-262 times per second, I am approximately playing middle C. The driver make this simple because there is only one connection between the stepper and driver that you need to worry about, and that is the “step” input. This input on the driver accepts a series of pulses, and will increment the stepper one step per pulse.

General program flow:

Well, obviously this part isn’t working, or I’d be posting about a completed project right now…I thought it would be straightforward (and maybe it actually is, but I’ll discuss the problem in a moment).

– A main loop keeps a pointer to the current “action” specified by the output array of miditones, and controls several flags that sets whether the system is currently playing music and/or delaying, and changes the notes directed to each channel.

– An ISR (or several) is used for timing so that delays can be implemented properly, as well as sending pulses to the steppers.


So why aren’t I done?

Actually, I might be. So one obstacle I’m running into is that I don’t have enough physical channels to play all the music I want to. miditones analyzes the .mid files and outputs information on up to 8 channels, but I only have 3 steppers. Have I tried playing with only 3 channels? Yes, and it definitely sounds incomplete, and very disappointing. If I could just borrow some steppers, maybe this project can come out of project purgatory.

With that said, if anybody should like to try to complete this project, leave a comment or send me an email and I’ll send the source code.

Learning from Others: Ben Heck’s Foot Pedals for Gaming

Just as how I started this blog in order to share what I’ve learned, I follow and continue to discover other people’s works and projects to learn from (and they’re often waaaaaay more experienced and professional, too). Now here’s a guy I’ve been following since my foray into the hobby electronics/maker movement and the like: element14’s Ben Heck. He has really interesting projects, like this one:

As you can see, he programs and makes a foot pedal device that can act as secondary keyboard inputs. It’s got a teensy core, and as you’ll see in the video, not a terribly complicated program. Ben’s got lots of projects like this, and if you’re a gamer in any capacity, you’d probably get a kick out of a certain few.

*Anyway, there is a secondary interest in this post, and I’ve got to drop some names, so go check out element14 (and you might have already if you were thinking of buying a RPi) and for things to use in your projects!

Computer Vision

This blog needs content, but grad school has all but consumed my life. I don’t have much time to organize more recent things I’m doing, but I did manage to dig some old stuff up, and I hope that they will still be interesting to readers. Here are some computer vision assignments:

Computer vision is arguably one of the most interesting class I’ve taking in my time here at Georgia Tech. The videos above show a program tracking Romney’s face/hand by means of a particle filter. Imagine a template taken beforehand being compared to a window centered at each of the dots, with the correlation between the template and window defining each dot’s weight. The red window results from taking the weighted average of each dot’s position. Neat stuff.

And here is some feature matching by means of a SIFT plus RANSAC algorithm:


Despite the picture being rotated, this program can find corresponding locations. It can even match a template to more complicated transformations. I can try to have source code put up if I can ever find them.

Until next time.

Updates 2/7/14

Since graduating, I have begun graduate studies (still at Georgia Tech), and started working at Georgia Tech Research Institute (GTRI) as a GRA. Even though these courses and work have already begun to consume my life, I still plan on updating this blog with all the interesting things I’m learning about, at and away from the classroom. There are some new stuff available on here, such as a dedicated resume page and updated About section. I also finally bought the domain name (no more “”).

To kick things off, I’d like to learn how to make my own PCBs. Yes, it’s true that I don’t know how, because even though I got a degree in electrical engineering, my coursework was largely on the theoretic side and with more computer science-y work. I don’t regret it, but I do regret not spending more time “doing”. It’s been tough reconciling that with a new interest in hobby electronics and hardware engineering. I found this:, and I think it will be a great starting point. I’m excited at the prospect of making more professional projects, especially when so many of mine have never gone beyond the breadboard/perfboard.

Not today though, this pipeline with cache simulator won’t write itself.

FPGA stuff

A few weeks ago I got myself this little beauty

2013-12-26 06.03.59

It’s a beginner FPGA development board, which I got as a means for myself to learn about FPGAs and VHDL/Verilog, something that my coursework was lacking in, despite my recent growing interest in embedded systems. Since graduation I finally had some downtime to play around with it. For anyone wanting to join me, I’ve been following this site:, and it’s fantastic. The modules are easy to follow, I’ve flown through them and having a blast.

I’ve implemented a simple state machine. This state machine will detect the switches being thrown in the order: 8, 7, 6, 5, where 8 is the leftmost switch. When this happens, the four leftmost LEDs will light. The four rightmost LEDs simply reflect the current state, and it won’t mean much to the viewer without seeing the implementation details.

Pick a number between 0-9

While cleaning up the semester’s mess, I came across this pamphlet:

2013-12-18 17.04.05

I have no idea where it came from, but I looked through it, and found some interesting circuits, such as this one:

2013-12-18 17.04.27

It’s a “random number generator”. There are two main components: an oscillator circuit and a decade counter, pretty much split down the middle. About each one…


This involves the two NAND gates on the left. If you’d like, you can replace then with inverters, however, because tying the inputs of a NAND gate together produces the same function as a NOT (check: 1 NAND 1 = 0, 0 NAND 0 = 1).

Putting inverters together in a circuit with feedback creates an oscillator, like so:


And depending on the value of the resistor and capacitor, you can make it oscillate at different rates.

Decade counter

“Decade” means 10, so a decade counter counts to 10. The specific IC used here (4017) has 10 output pins that are driven high depending on the current count, instead of 4 pins that represent 0-9 in binary. Counts are advanced by a clock, so the oscillator output circuit connects to the decade counter at the clock pin, and the circuits are separated by a pushbutton.

To see what pin is being driven high, and hence see the current count, you can put a LED in series with each output pin, and the LED will light according to the count.

When the pushbutton is activated, the decade counter sees the oscillator output and will begin counting. If the oscillator is operating fast enough, seemingly “random” numbers can be produced by letting go of the pushbutton.

Because I’m on break and I just happen to have the components and ICs on hand, I built it.


I’ve been pretty good about not turning this into a personal blog, rather than a professional one, but here’s some pertinent personal news: as of Saturday, Dec. 14, 2013, yours truly is a graduate of the Georgia Institute of Technology with not one, but TWO degrees (Electrical Engineering/Math)! What does this mean? Unfortunately the excitement of the culmination of the last 4.5 years quickly washed away when I realized I’m still committed to graduate school. But this is still a major milestone that I’m proud to share. Woohoo!

They don’t give out the diplomas as you walk the stage though (things that could have been brought to my attentION YESTERDAY). I was handed a roll of paper, which I promptly unrolled as I returned to my seat.

2013-12-14 11.14.55(I half expected a picture of trollface)

I’ve since decided it’s rather appropriate.