Arduino Without The IDE

Some of you may remember that I've previously blogged about shrinking down an Arduino by buying the ATmega328P-PU and associated components. This is a great way of using the Arduino in a more permanent setting as it is much cheaper than using a full Arduino. I did, however, have a problem in that the Arduino IDE seemed to use the wrong upload speed when trying to burn the bootloader or upload a sketch. This meant I had to mess around copying the command out of the IDE and into a terminal and then tweaking it so that it used the right upload speed. Honestly while the IDE is easy to use (especially for novices) it isn't really a very good IDE and suffers from a number of problems which really annoy me. So I set out to look for an alternative way of compiling and uploading code to the Arduino.

Given that I already knew that the Arduino IDE is just a front-end to a number of other tools which are responsible for the compiling and uploading (which is why I could copy the relevant commands into a terminal and tweak them) I knew that it was likely someone else had already figured out how to use the Arduino without the IDE. In fact a couple of people have published details on how to do this, but the most comprehensive approach I found was by Tim Marston.

Tim's arduino-mk project supports compiling Arduino code, uploading it to an Arduino, and has a serial monitor as well. As the project name suggests this is all implemented as a classic Makefile meaning that it works from the command line, leaving me free to choose whichever code editor I want to use. The really impressive part though was that it worked first time; not only to upload code to my Arduino, but also to upload code to my hand-built replacement. There were, however, a few missing features.

Firstly the build process didn't pull in any libraries in the users sketchbook folder (which the IDE does), meaning some code I had didn't initially compile. Secondly the project didn't have any support for burning the bootloaders to new chips, something the IDE should be able to do, although in my experience it doesn't work properly (the same upload speed problem). Fortunately arduino-mk is an open-source project and Tim is more than happy to accept patches for bug fixes or new features. Whilst I don't think I've ever written a Makefile from scratch before, I know enough about how they work to add to an existing file and so with a little effort I managed to figure out adding support for both libraries in the sketchbook folder and the burning of bootloaders. Both features have now been incorporated into the latest release which means everyone else now has access to them as well.

If you are happy working from the command line and aren't really a fan of the Arduino IDE then I would definitely recommend trying out arduino-mk.

Silence, Most Definitely, Isn't Golden

I travel quite a bit for work, which means I end up spending quite a lot of time in hotel rooms, often working late into the night. These long evenings are made slightly better with a little music, and I prefer not to spend my time wearing ear phones. Fortunately my laptop has a decent sounding set of speakers.... when they work at all.

When I first got the laptop the speakers were working, but the first thing I did was to do a fresh install of Ubuntu (version 12.04 at the time). It took me a few weeks to notice, but the fresh install had left me with a laptop with no sound.

Periodically I tried to fix the problem always without any success. The final straw came when I had a long morning in Hannover, with only a little work to do before the meeting was to start in the afternoon. It was too cold to spend too long outside so I set about finding a fix.

Three hours and a lot of swearing and rebooting and I finally had sound working. Annoyingly I didn't write down exactly what I did to fix the problem, and so when last week I upgraded Ubuntu to the newest version (13.04) I found that I had no sound and couldn't remember how to fix the problem. It's taken me almost two hours to find the solution again so this time I'm writing this post to both help anyone else having the same problem and to stop me having to figure it all out for a third time next time I upgrade Ubuntu.

I followed almost every suggestion I could find on the web to diagnose sound problems, yet in most cases my laptop was already configured as suggested. I was almost ready to give up when I came across a page which suggested disabling the Auto-Mute Mode in the alsamixer control panel; you can see this in the screenshot. This looked promising but there was one problem -- When I ran alsamixer I didn't have a Auto-Mute Mode option.

Another forty-five minutes of fruitless web searching followed before I eventually discovered a way of changing the audio driver to show all the available options. Unfortunately this uses the daily build of alsa which I expect is why it got disabled after the upgrade to the newest version of Ubuntu. Anyway, the trick is to run the following commands to add the relevant repository and then to install the daily build of alsa.
sudo apt-add-repository ppa:ubuntu-audio-dev/alsa-daily
sudo apt-get update
sudo apt-get install oem-audio-hda-daily-dkms
Once completed you can then run alsamixer and you should find that the Auto-Mute Mode has now helpfully appeared. Simply disable this option and you should find that you're sound starts working. As far as I understand this option is related to sensing if you have plugged headphones in and if the internal speakers should be disabled or not. This means, although I haven't tested this, that if you disable the Auto-Mute then plugging headphones in my not stop sound coming out of the speakers, but that is an easy problem to deal with.