From iPhone to Android

8th July 2010

Given the news that the new iPhone 4′s revolutionary external aerial system is all but useless, I have decided to jump ship and embrace the Android revolution. My new HTC Desire should be arriving within a few days time; just enough time for me to get to grips with Java.

My 18 month contract with O2 ended this last week and so for the last couple of weeks I have been exploring my options. I had already had the phone unlocked by O2 and as I won’t be upgrading for a while, I was after the best short term contract available. Vodafone’s £20/month SIM only deal offering 600 minutes, unlimited texts and 500MB mobile internet seemed to be my best bet. After quickly scanning the contract I noticed that they did not restrict how the data could be used, i.e. tethering should be possible. A quick phone call to their sales staff confirmed this, or so I thought.

After installing the new SIM, I quickly headed to the network settings to try out tethering. Instead of breathing new life into the phone however, the ‘Internet Tethering’ button merely brought up a message informing me that the feature was not enabled and that I would have to contact Vodafone. Perhaps it needed a restart? No, it turns out that if you use the iPhone with one of the official carriers, then they must authorize it. Without jailbreaking the phone, which in hindsight might have been a better option, it is not possible to enable it even on an unlocked phone.

Given that I had already clarified with Vodafone that data could be used in any way, I gave them a call to request tethering be enabled. Perhaps unsurprisingly, the first assistant I spoke to said that this was not possible on a non-iPhone contract. I then had a relatively lengthy conversation with his supervisor who told me that the iPhone plans (which have tethering enabled) are set by Apple and their is no way that Vodafone can change these or offer any form discount. When I put it to her that customers who end their 18 month contracts will likely ask for a discount as the contract has been subsidising the phone, she said that a discount would be unlikely. Her manager however was able to give me a discount, not a perfect one admittedly, but an acceptable one.  For £20/month for 6 months I get 300 minutes, unlimited texts and 1GB data which can be used for tethering.


First off, I wouldn’t consider myself an audiophile but I dislike hearing music through cheap speakers. My HiFi consists of a pair of Bowers and Wilkins DM601s and I also have a pair of Sennheiser HD555 headphones. Whilst these are not the best on the market, they do sound exceptionally good. Usually I don’t listen to music on the go, but when I do the Senns aren’t suitable and as we all know the standard iPod earphones are simply terrible. For £17.99  I picked up a pair of Ultimate Ears MetroFi 220 from Ultimate Ears manufacture some of the most well respected IEMs on the market but the MetroFi are designed to capture to general consumer market who are looking for decent quality without breaking the bank.

Comfort and Fit

UE provide three sizes of eartip; small, medium and large. For me the medium were a perfect fit, however I can well believe that if none of the sizes are appropriate for you they may be quite disappointing. I wore the earphones on my train between London and Bristol which was about a 1:30 hour journey. They certainly did not block out all sound but they knocked out the sound of the train and attenuated people’s voices making the journey much more pleasant than it might otherwise have been. I was quite surprised at how noisy the carriage seemed when I took them out at the end of the journey. In terms of comfort, I found I very quickly forgot they were in and my ears did not feel sore at the end of the journey.

Sound Quality

As I have already stated, I am no audiophile so my review is purely my uneducated opinion. The frequency response of these IEMs is quite reasonable for a cheap pair of headphones, most of the treble and mids appear to be there and whilst the bass doesn’t reverberate around your head, it is reasonably respectful. In fairness, when I tried the Sennheiser CX500s I felt they were too bassy and hence unenjoyable. For listening rock, they are relatively balanced; vocals are clear, the guitars don’t sound too harsh and the bass guitar can be clearly heard but is not intrusive. Mozart’s Piano Sonatas certainly showed up the flaws in the treble, the phones sound almost murky and certainly don’t make for enjoyable listening. Film music was handled was handled better; some energy is certainly lost but there isn’t too much to complain about. Dance, Trance and Hip-hop fans will probably want a little bit more bass however for the casual listener I think they pretty good. The soundstage is certainly improved with auto panning effects incorporated into these genres.


Overall I would say the 220s are very good for £17.99, they certainly do not compare to Sennheiser HD555 but it would be madness to expect them too. They are a huge improvement over the standard iPod earbuds and for many people will probably represent a vastly superior sound. If the eartips fit your ears, the sound isolation is good and they are not uncomfortable. If I were to lose them I probably would replace them with a more expensive model such as the SuperFi 5s however the are over 3 times the price.

SparkFun have an excellent range of accelerometer breakout boards for hobbyists, mostly based on the ADXL3xx series of chips. The vast majority of these are happy to run at 2.4V-5.25V and so can easily be plugged directly into the Arduino. Unfortunately the ADXL335, which I believe to be the newest and cheapest chip, does not accept any higher than 3.3V.

Opening a basic serial connection to the Arduino in Matlab is not difficult and is documented. Data is sent to the device using the fprintf() function and received using fscanf().

s = serial('COM3', 'BaudRate', 9600);
fprintf(s, 'Hello World!');
line = fscanf(s);

If we have data continually being sent by our device there are two ways of capturing it. We can create a loop within Matlab to constantly check if any data has been received however this doesn’t seem like brilliant coding practise. Alternatively we can make use of the Matlab’s BytesAvailable event and read the input buffer only when data is received.

Unfortunately, unlike languages like C++, Matlab is only able to pass variables by value and not by reference. So if we create an array in our workspace to hold the received data, our callback function will be unable to update it. However in Matlab it is possible to nest functions within the body of another. The variables defined in the outer function will be accessible to the inner function.

% Calling the function myFunc will display the number 10.
% Demonstrates that nested function has access to variables.
function myFunc

    myVar = 10;


    function innerFunc


The code to establish a serial connection is written into a Matlab function which also contain an array of all received data. The callback function of the BytesAvailable event is defined as a nested function and hence  can add to the data array when new data is received. This allows us to perform analysis on the data in parallel to it being read.

The full sourcecode of my function is shown below:
Read the rest of this entry »

There are plenty of tutorials explaining how to make an LED turn on for a pre-set period of time using the Arduino. However I have come across none which allow us to set the delay time using serial communication. As it turns out, getting an integer value from serial input is a little more complex than one might first think. To understand why, we must first understand how serial communication works.

Serial transfer is where we send each bit of data sequentially, one after another. The Arduino stores each byte (8 bits) it receives into its input buffer array. When we call the function, we grab one byte form the input buffer. So, if we send the number 100 we will read a one followed by a zero followed by another zero. To make things a little more confusing, each number will be ASCII encoded. We must convert each received byte to an integer and then join each individual integer into one value.

After a few attempts to concatenate integers,  I came across this insightful post on the Arduino forums. The following code is adapted from the code suggested by user PaulS.

value = 0;

while (Serial.available() > 0)
  value *= 10;
  value += ( - '0');

We start by initializing an integer to zero, this will hold our read value. Within the while loop, the value is multiplied by 10 to shift the place value of the digits to the left. In line 6, we subtract the ASCII value of character zero (48) from the input byte (which we know is ASCII encoded) and hence obtain a numeric value. It should be noted that each number is placed in the units column and then shifted to the left each time another value is added.

I found that at a baud rate of 9600, the Arduino was executing the run loop faster than the serial bytes were being received. As a result if I sent the number 100, the while loop only ran once and so the value was set to 1. The one ms delay gives the Arduino time to receive the next byte.

Full source code is provided below:
Read the rest of this entry »

If, like me, you find yourself struggling to remember the colour codes for resistors, then you need the ResistorCC app for the iPhone. Unfortunately the free version doesn’t have reverse lookup though this isn’t much of a limitation. Check out the screenshot below…

Read the rest of this entry »


Get every new post delivered to your Inbox.