DCSIMG
Playing music on netduino via a web browser - Scenes From A Developer Memory - Site Root - StudentGuru

Playing music on netduino via a web browser

Please check the new and updated blog at http://www.dgkanatsios.com

Current blog post can be found at http://dgkanatsios.com/2015/01/16/playing-music-on-netduino-via-a-web-browser-3/ 

I was really lucky lately to get my hands on a netduino. I’ve never programmed on such a small device before and I have to confess that it’s really fun and awesome!

First, take a look at the video to see what’s going on. Basically, we are instructing the netduino to play a specific set of noted via a web browser on our PC.

 

We’re using a netduino device. For the unaware, it’s a small device that runs a small version of the “big” .NET Framework, called .NET Micro Framework, so one can easily use C# and Visual Studio to code for it. It’s connected to a Piezo, a small component that can create some noise.

WP_20150115_11_39_20_Pro__highres

We’ve connected the netduino to our PC via USB cable and via an Ethernet cable. The USB connection allows us to deploy and debug our stuff on the device whereas the Ethernet cable allows us to make a small LAN between netduino and our PC. Without any more hassle, let’s check the code!

Playing music

Code was found on Getting Started with Netduino book. It basically adds octaves on a hashtable, sets frequency and period, connects to the speaker (via PWM which is accepting input on the Digital 5 Pin) and plays the respective input. Check the full code here

image

image

Web Server

For the web server, we’re using Laurent Ellerbach’s small web server found here. For a description, check his blog post here. It allows us to serve a small page with a bit of JavaScript to accept notes request. Check the

image

The code to detect if the request contains a note to play is pretty simple

image

All in all, that was  rather easy and fun! Stay tuned for more .NET Micro Framework posts! As always, the code can be found on GitHub https://github.com/dgkanatsios/NetduinoPlayMusicRemotely

PS. Many thanks to Laurent for his help to get started, don’t miss his excellent .NET Micro Framework blog here!