Topics:- low cost Arduino clone with only very few parts- programming an Atmega168 with the audio line of a PC

IntroductionFor a long time I was building little microcontroller circuits which played with leds, make sounds or controlled little robots. I was always looking for a low cost circuit to program my gadgets because I like to give some of them to my friends as a present and I wanted to enable the people to download new programs to this gadgets. Imagine if you build a simple low cost led gadget which produces some light patterns. After a while you would become bored about the patterns the gadget produces. How nice would it be to download some new patterns?To do this, you need a bootloader in the microcontroller.The bootloader described in this article might be used to build a kind of “low cost” Arduino for daily use when you don't want to spend the money for a real Arduino but to be able to simply reprogram your circuit. I call it Audioino because it can be programmed from the audio line of a PC ( and because no one else seems to use this name )

How to build your Audioino?1.program the provided audio bootloader onto a fresh Atmega168 (you can use the the sketch “ArduinoISP” in the examples folder of the Arduino IDE for flashing - or find someone who owns an ISP programmer2.build your Audioino ( you need an Atmega168, 3 resistors, two capacitors, 1 LED, audio jack and a reset switch )

How to download your Arduino programs to the Audioino?

1.develop some programs you like with your Arduino IDE2.compile it3.find the hex-file the IDE created4.connect your Audioino to the line out of the PC ( downloading works probably best if the volume is set to maximum ) and press reset5.Use the provided Java program to transfer the HEX code via your audio line-out to the "Audioino".

After pressing reset the status led will blink for 6 seconds. During this time the bootloader waits for a program from the audio line. After flashing the program it is started. If no data is received, the bootloader terminates and starts the last program stored in the microcontroller.

HistoryA common way of storing programs 25 years ago was to use tape recorders to store the data as audio signal.The SOUNDRX project ( http://www.mikrocontroller.net/articles/SOUNDRX ) uses this technique to transmit data by the audio line of a PC to a microcontroller. A software was developed to send data to a Atmega microcontroller by the audio line of a PC. I proposed to use an encoding scheme called “Flankenkodierung” ( edge coding ) and an interface circuit consisting of a 10k poti and a 10nF capacitor. Tue to his, the project reached a data transmission speed of approximately 20kBit/s and reduced the hardware expenses to a minimum.Because this interface has to be calibrated and the memory foot print was to large to fit into a 1K bootloader I developed a new version which has half the transmission speed but needs no calibration, fits in the 1K bootloader area and is self adapting to the baud rate. Therefore you can use Atmegas with 8MHz or 16MHz system clock without calibration or different software setup. I also developed a little Java program for downloading a program to the microcontroller. It converts a HEX-File into a WAV-File and sends it to the line out of a PC.

Hardware IssuesUsually a 10k resistor is connected between reset an VCC to prevent unintended resets. I found that for my applications the circuit is well functioning without that resistors. If your circuit should work in a more difficult environment: add the 10k resistor.The line-in signal is connected to the TxD pin. This may seem strange. The intention behind that is: you could transmit data from the microcontroller to the PC by simply using printf if you connect to the line-in of the PC (The Java program is not capable of receiving data yet but probably someone wants to develop it. A resistor may be inserted at the TxD pin to decrease the signal amplitude for transmission. ). To reduce part costs, there is no crystal in the schematic. This means for your application that it only runs half the speed of an Arduino-Uno. If you need more computing power provide a crystal to your circuit and setup the fuses of the Atmega when you program the bootloader in the fresh microcontroller.

AttentionThe 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.

Improvements and Erratas- the capacitor in the audio line should be changed from 10nF to 100nF. This improves design stability.- to download data, the volume has to be at a suitable level. It should work best at a volume level of about 80%.