Program an Arduino using your sound card

audioino_programming_arduino_with_sound

[Chris] wrote us to share a neat technique he has been using to program the Arduinos he uses in his projects. He likes to build bare bones Arduino clones rather than sacrifice full dev boards, and instead of programming them via traditional means, he is using his computer’s sound card.

He builds a simple dead bug Arduino (which he calls an Audioino) using a handful of resistors, a pair of caps, an LED, a reset switch, and most importantly – an audio jack. After burning a special audio bootloader to the chip, he can connect the Arduino directly into his computer’s speaker port for programming.

Once the microcontroller is connected to his computer, he runs the IDE-generated hex file through a Java app he created, which converts the data into a WAV file. With the Arduino put into programming mode, he simply plays the WAV file with an audio player, and the code is uploaded.

He says that this method of programming comes in handy in certain cases where he builds things for friends, because they can easily update the software on their own without a lot of fuss.

86 thoughts on “Program an Arduino using your sound card

    1. I remember that we had a radio show that was sending programs over the air for you to record. They had to cancel the ‘show’. You can take a guess on why.

      1. Back in the 80s, using a BBC Micro with a teletext adapter box it was not only possible to read teletext/ceefax, once a week they broadcast programs that you could download. Took an age because they were sent in many many small chunks.

        Sadly I got my own BBC Master Compact with a teletext adapter about a week after they stopped broadcasting programs.

        Programs broadcast over the tv waves man!

  1. Neat technique but it’s sad what people call arduino’s nowaday. I don’t see how a bare AVR with some fancy bootloader should be called arduino or xduino for the matter.

    1. Agree. I remember when someone did this but with a USB jack and we asked why it was an arduino… the general consensus cause it had the arduino bootloader… fair enough. This is an AVR microcontroller with a neat bootloader. Cool project though.

    2. What more is the Arduino besides the bootloader, IDE and the class library? Does it really matter, if the thing does not have pin headers in uncomfortable places and a USB programmer is not built in?

  2. …Brillant!

    This reduces the cost of an Arduino clone to under $10! $~4 for micro, plus a $1.50 audio jack, and approx $1 in resistors, caps, and other items.
    And that was at one off purchase prices…

    I might have to start using this for long term embedded projects that don’t need shields. Updating would be as simple as bringing over a MP3 player. So much easier and cheaper than using an actual arduino to update, or wirelessly with an xbee, or using a usb adapter.

  3. I wondered about doing this exact thing so I could program them using a cell phone. You would just drop all your sound files (programs) into DropBox on your PC and then use your Android phone to program while out in the field.

    This is exactly what I was looking for! Great job!

  4. This will save my day i guess. I am currently working on a small project where i am using the arduino ide but don’t want to include a full board in my system. the atmega is enough.. I will surely give it a go. And 10/10 points on creativity here fokes.

    1. @Benjamin I’m really certain this alone will not replace an Arduino. This only programs the microcontroller. While that is one step in eliminating the need to dedicate an entire Arduino to on project, you will still have to design,and build the supporting circuitry. Build anyway as it seems there are plenty of circuits published to the web.

  5. man, some peoples are crazy, that’s it, really sick crazy peoples that’s what they are.
    and I’m redundant, that’s the kind of person I am, redundant.

  6. Cellbots and folks got this to work dynamically on a cell phone for serial data. I’m sure you could program using your cell phone and an audio file (in fact thats how i proved the dynamic stuff could be done).

    Just make sure you store it as a wave in some native bitrate (arbitrary sampling was not accepted by the phone’s DAC).

    Very nice hack!

      1. Simple. Make a program that looks for xxxxHz tones and then figures out which 2 are being used at the same time. This gives you 2 bits from each frequency.

        Hint: If you are planning on using a general FFT, you’re doing it wrong! An Apple II did this in software…
        If you have trouble, this is old school bare metal machine language hacking to get the most from the least at it’s finest. They gave us all those counters for a reason.

      2. I wanted to do the opposite – use a sound card to spy on an I2C bus(possibly slowed down). Or at the very least, to record the output of a bus spy’s buffer. I was thinking that I wouldn’t even need modulation at low enough of a speed. Just post processing by the ever-so-convenient GigaFLOP CPU that just happens to be connected to the soundcard.

        Hehe, nice use of a common output port that will likely be on ANY computer you’re likely to come across.

    1. hahahahaah you win an internet today XD

      But now I’m curious how this sounds, if it sounds at all.

      A freaking orgasmic set-up would be an old telephone modem (talking about with the handset and all that) programming through the network.

  7. This will probably play well with my audio-to-serial thingie that was on hackaday a while ago… Only thing is, how do they deal with levels? I thought you’d need an op amp or at least a transistor to do level shfiting. Maybe that’s just for phones since they aren’t designed to drive big speakers!

    1. People take note that the LINE OUT of the soundcard is being used, NOT the speaker output. That rules out some of the musing taking place, except using a microphone for “wireless” programming. You know of course the telephone is going to ring when you do that.

  8. Just wondering about what would happen if someone played an arbitrary sound file.
    Would the bootloader burn it and bork the chip or just reject it?

    Also, while ok if you’re just using for upload new firmware for friends etc, having to press the reset button at the correct time to trigger reprogramming would not be ideal/appropriate for a commercial product.

    Thinking about it though, if you used a stereo signal, one channel could be used for data and the other could send a short pulse which triggered the reset line to be pulled low.

    You’d need more components than would fit on a deadbug design, but if you were making a commercial product that would be an issue.

    Overall, very interesting work.

    1. Oops. Last paragraph should read:
      You’d need more components than would fit on a deadbug design, but if you were making a commercial product that would NOTbe an issue.

    2. Actually, the only extra component would be a capacitor, so it shouldn’t be a problem.

      (and the original arduino didn’t do autoreset either…)

  9. Wait. The link doesn’t seem to indicate that a special boot loader is necessary (other than just the standard arduinoISP boot loader). What’s up?

  10. Well if it works as well as Chris describes, it may lead more to duplicate projects that use this family of microcontroller. A thank you to Chris for taking the time to share this. Keeping in mind the differences between microcontrollers could this be used to program the on board flash of other microcontrollers?

    “program the Arduino”; so has Arduino become synonymous with the Amtel AVR microcontroller? Just one more thing we need to keep in context when we read articles. I suppose to start referring to the actual microcontroller would confuse the hell of those who came to the world of microcontrollers, and electronics via the Arduino, and really don’t understand how versatile microcontrollers can be beyond the dedicated development boards.

    1. Valid point. Since its not really an arduino its just a chip with some elegantly connected wires..

      Arduino is hard to disambiguate. Its a hardware platform as well as an ide and a set of libraries… So it could be some random Atmega running “Arduino”.

      I consider Arduino an ecosystem :)

  11. Thats impressive.

    I was thinking along those lines to see if a micro could be programmed using a Bluetooth headset so any old cheap touchscreen phone could be used to burn a chip.

    It got me thinking though, what about using this to program the Microchip PIC series as these often need an expensive programmer.
    What about 24Cxx and larger E2PROMs?

    1. people always bitch and moan about “expensive” microchip programmers, but the pickit2 and pickit3 (clones) are like £20 – or just use a parallel port programmer. in my experience, atmel programmers are of similar cost.
      In reality, the “debug” functionality justifies the price tag imo, and allows you to do stuff you just cant do without a huge load of code overhead on a usb bootloader.

  12. Great job, this is one of my favorite hacks on here in the last couple of years. Throw that .wav on an iPod and you can update it anywhere. If you could operate the Arduinos using audio that’d be even cooler.

  13. My first post ever was deleted earlier after years of checking this site everyday. WTF?? I thought this hack was awesome. The fact that you can throw an update on an iPod in .wav form is really slick. I’d like to see an “audio hack” category here

  14. I was really, really, really, really, really excited about this… Until I read that you still need to burn this audio boot-loader? It’s still cool, just not quite as practical as I had wished. Sad face.

  15. great and nice prototyping with resistor n such, I been wanting to implement some digital communication out an audio jack, What think yalls is the achievable baud?

    20khz / 8bits = 2.5MB/s

    could it be?

  16. Thank you for all the nice comments.
    If someone didn’t find the bootloader link:

    http://www.hobby-roboter.de/forum/viewtopic.php?f=4&t=127

    Remark:
    The IDE produces WAV-Files to program the Audioino. Converting this WAV-Files into MP3s will not work because MP3 is not a lossless compression. Therefore if you want to distribute your programs as sound file it has to be a WAV.

    Hardware issues:
    the capacitor in the audio line should be changed from 10nF to 100nF. This improves design stability.

  17. “great and nice prototyping with resistor n such, I been wanting to implement some digital communication out an audio jack, What think yalls is the achievable baud?”

    In this project

    http://www.mikrocontroller.net/topic/224911

    the achieved about 20kBit/s. For digital transmission this is close to the maximum possible. If you use audio out with analog signals and a quite complicated algorithm, the theoretical maximum would be the data rate put into the sound channel: 44kHz*16bit

  18. I like to use IR for programming chips. You only need add an IR sensor like the ones used for remote control. Cost about $1 each. Write the program on the pc and output it as a series of pulses over serial. Also good for environments where you don’t want to physically connect the device.

      1. For programming you can use laptops that have IRDA ports, most do. I’ve done the sound card thing and while it works okay I finalized on the IR route because of the ground isolation it provides. I had issues with some laptops having power supplies that maintain a ground connection to the wall outlet and that is bad when working with devices powered off isolated supplies.

  19. Why are you people calling this an “Arduino clone”? It’s a freaking atmel processor. I have been playing with these since the 90’s… Now someone starts calling them “Arduinos” and its suddenly new to you all!? If I call my old buick a ferrari, will one of you pay lots of moneyz for it???

    1. I guess it depends on your definition of arudino clone. If yours is one that requires the shields to be used then I guess it isn’t a clone. My definition is anything that runs the code the arduino libraries and IDE output. One of the things holding the arduino back is the lack of people willing to use it without a shield . There is nothing wrong with arduino programming like he has shown here and yes to me that makes it still an arduino clone.

  20. I just dont get it, you have to load a bootloader, so that means you already have a programmer. so … why? is 4 wires really that hard to hook up?

    1. If you don’t get it then you need to read the article again and again until you do…

      >He says that this method of programming comes in handy in certain cases where he builds things for friends, because they can easily update the software on their own without a lot of fuss.

      He’s got a programmer (that’s how he gets the bootloader onto the chips in the first place) but not everyone does.

      This means that when he makes something for his friends, or even sells something commercially, not all of his friends/customers need to have programmers also, they can just play a sound file on their computer.

  21. now all we need to do is to bit-bang the sound through USB and we can program AVR’s using USB with no USB-Serial adapters or PL-2303 chip needed! this is just fantastic!..:)

    — GTG find those USB speakers… :D

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s