Tiny Robot Jazz

Microcontroller-based projects don’t have to be fancy to be fantastic. Case in point: [r0d0t]’s “Musicomatic: the random jazz machine“. Clever programming and a nice case can transform a few servos and a microcontroller into something delightful.

musicomat_schematicsHardware-wise, there’s really nothing to see here; a speaker and some servos are hooked up to an ATmega328. We think it’s cute to have the microcontroller control its own power supply through a relay, but honestly a MOSFET in place of the relay or better still using the AVR’s shutdown sleep mode would be the way to go.

Nope, where this project shines is the programming. Technically, it might make some of you cringe — full of blocking delays and other coding “taboos”. But none of that matters, because [r0d0t] put his work in where it counts: the music. You simply must hear it for yourself in the clip after the break.

The basis of making music that humans like is rhythm, so [r0d0t] doesn’t leave this entirely to chance. The array “rhythms” has seven beat patterns that get randomly selected. The other thing humans like is predictability and repetition, so choruses and “improvs” repeat as well. All of the random notes are constrained to the pentatonic scale, which keeps it from ever sounding too bad. (The secret sauce of Kenny G.)

In short, [r0d0t] packs a lot of basic music theory into a very basic device, and comes up with something transcendent. We’re a bit reminded of the Yellow Drum Machine robot, and that’s high praise. Both projects are testaments to building something simple and then investing the time and effort into the code to make the project awesome.

For another slice of [r0d0t]’s excellent minimalist pie, check out his take on the classic Snake game: Twisted Snake.

https://www.youtube.com/watch?v=bMw7JR2N3SU

17 thoughts on “Tiny Robot Jazz

  1. Have to admit, he’s got a very good point about the “no really, absolutely zero standby power”, although I wonder how the 150mW needed to keep the relay closed while playing compares to the power consumption of the servos…

  2. That’s awesome!!! Super catchy and cool!
    This is an excellent demonstration of music theory!
    I love that the tunes are randomly generated with a
    Set of theory applied on top! Very nice!

  3. Putting the AVR to sleep won’t help because the servos will still eat power. Of course, using a proper FET would still result in negligible standby power consumption.

    1. In general, active servos will use significant power to hold position if something strong enough is pushing them away from the desired position. Since the loads here are pretty light, even gravity may not be enough to force the drivetrain out of position. So when not moving, these servos will only draw power for their processors.

      In this circuit, when he shuts the relay off, power to the whole system is disconnected so the servos won’t draw any power at all (assuming they are connected to Vin or to the batteries downstream of the relay).

  4. I have a circuit where I used a mosfet to turn everything off. The ON button bypasses the signal from the CPU that keeps things on. The first thing the CPU does when it boots (hopefully before the human has had time to release the button) is to request staying on. When the CPU detects inactivity it shuts itself off.

    The thing is: Official specs say that the mosfet will still pass around 1 microA even when off. So “completely off” is not entirely possible. On the other hand: In practice the mosfet performs 100 to 1000 times better than spec…

  5. Very Nice! I especially like the “acoustic” rhythm section. Good to see something more creative than another garage door opener done with an arduino for a change.

  6. Really like this project.
    What did the cap on the relay coil solve?
    Most are cautious about relays and add a revers bias diode instead (http://en.wikipedia.org/wiki/Flyback_diode).
    Most embedded processors have a very low stand by current demand. Some, if you will tolerate loosing your data, are even less.
    Why don’t you use 1 of the servos to turn the power off. Use a micro switch for mechanical hysteresis. Arrange it so a new position (fully up) will cut off power. Shot the switch with the power button to activate playing. And make it part of your initialization code to move that servo back to a normal playing position.

    1. A piezo buzzer works great, as long as you connect it to a nice passive amplifier. But yeah, these ones are almost inaudible.

      Then again, when I’ve played around with one of those 110Ω magnetic speakers, it was also really quiet.

Leave a Reply

Please be kind and respectful to help make the comments section excellent. (Comment Policy)

This site uses Akismet to reduce spam. Learn how your comment data is processed.