Netduino: MP3 Player Shield

A couple of friends of mine gave me one of SparkFun's MP3 Player Shields for my birthday (this guy). I just got my order of Arduino Headers (strange how SparkFun don't send out shields with these by default) and finished soldering them on.

I've been playing around with it for a bit, and have just figured out how to read the mp3 file i placed on the SD card. The first thing I needed to do was to upgrade the firmware on my Netduino, because the firmware that comes with it does not support SD cards. The version 4.1.1 beta 1 (this guy) does the trick.

Once that's done, the next thing to do is to add references to the System.IO and the SecretLabs.NETMF.IO dll's (in your project for those people following along at home), and to include the using statements:

using System.IO;
using SecretLabs.NETMF.IO;

I placed an mp3 file (audio.mp3) in the root of my micro SD card, I don't see the need for any sort of fancy hierarchy (that may come later). Speaking of root, now's a good time to name the root of your SD card (i called mine MP3SD). Before you can read, you will need to mount the SD card. If you've been paying attention, you'll have noticed that the SD card chats to the Netduino over SPI and is sitting on pin 9, waiting for something to happen. So lets mount the thing:

// mount MP3 sd card
String sdroot = "MP3SD";
StorageDevice.MountSD(sdroot, SPI_Devices.SPI1, Pins.GPIO_PIN_D9);

Next up, lets try to read the directory structure, see whats happening with the files on the card:

// load mp3 file
String[] files = Directory.GetFiles(@"\" + sdroot);
Debug.Print("Files in root: " + files.Length);

String mp3File = "";
// for each file in the root
for (int i = 0; i < files.Length; i++)
    // if it is a valid mp3 file
    if (files[i].IndexOf(".mp3") != 0)
        mp3File = files[i];

// print out the filename
Debug.Print("MP3 File: " + mp3File);

At this point, if you look at the output log (ctrl + alt + o), you will see something similar to:

Files in root: 1

Pretty cool, eh? When i figure out whats next, i'll write an update.

.NET Micro Framework: Threads

Turns out its pretty easy to spawn a new thread in the .NET Micro Framework. First thing's first: make sure you've included the threading namespace:

using System.Threading;

Next, create a function that you want the thread to run (like blinking the LED):

private static void BlinkLed()
    OutputPort statusLed = new OutputPort(Pins.ONBOARD_LED, false);
    // do forever
    while (true)
        // toggle LED state

Now you just need to spawn it:

public static void Main()
    // spawn thread
    new Thread(BlinkLed).Start();

    // do other stuff

And, done!

Melbourne Wireless

Melbourne Wireless is a group of network nuts with too much time on their hands. They have created an open wide area network for anyone to join (provided they finance their own infrastructure). They are not an ISP and hence there is no internet access.

A friend of mine first told me about them and i was intrigued from the start. Recently (at work) I met with a member of the committee. He painted such a rosy picture, that I just couldn't resist.

I have signed up and created a node (nicked named KenNY - Node KNY). Next up: hardware acquisition.

And thus the adventure begins...