Monday, May 5, 2008

I'm Putting Together a Band (literally)

Got a lego mindstorms robotics kit. Uh, for benjamin's birthday...



No, actually for my birtdhay! Just a little bit early. It's really really fun. I made a little drummer guy. He's got one motor that turns some gears. There's a high-hat arm, and a bass drum arm, and a kick drum arm. The high hat goes 4x as fast as the other two arms, which alternate. So it's like this:



Hi-hat x x x x x x x x
Snare x x
Kick x x

Pretty much every AC/DC song covered right there.



Then I added an audio sensor and wrote a little program that waits for audio input to go above 50%. It resets the timer the first time it goes above 50%, then it waits for that to happen four more times. On the fourth time, it figures out how much time has elapsed since the first time, and uses that as a parameter for how much power to give the motor. So what you end up with is a program where you count off "one, two, three, four" and the drumbot starts playing a rock and roll beat. The programming API for Mindstorms is really interesting. You drag blocks (of course) that represent various functionality around. There's a block for "move", and another for "wait for input from sensor #2". Very minimal, but it seems like you can do just about everything you need to with a little jiggery. Is it Turing-complete? I'm not sure. It sure is fun to program something that actually moves around in the physical world in response to your words. I still need to fashion a little drum kit for him to play. And I have 2 more motors for his bandmates!



No comments: