Introduction: Music Party Player. DiscoVeryMusic for Friends!

Have you ever thought about a smart music player which can tourn on the music when you get home, or that plays the music according to the playlists of the people in that room? Now you can!

In this tutorial we will guide you throught a simple way to turn your friends phones (which support windows 8.1) into speakers. The Intel Edison will keep music files and the phones via wifi will stream it directly to your ear!

In order to do this, we will use:

  1. 1x intel edison #inteliotroadshow;
  2. 1x arduino breackout board for Intel Edison;
  3. 1x Grove Base shield;
  4. 1x (Grove sound sensor + connector);
  5. 1x Arduino RGB shield (https://store.open-electronics.org/index.php?_rout...);
  6. 1x Led Strip;
  7. 1x External power supply;

Bonus components YOU could use to make it even better:

  1. 4x (Button[grove or not] + connector) 2 of which could be used to adjust Volume, and the remaining 2 could be used to express satisfaction or dissatisfaction to the song playing;
  2. 1x Gyro depending on how the Edison it's rotating you could make a scratch, turning friends into dj (sjust for few secods).

Step 1: Do Not Worry!

You are going to build a smart party music player!

Step 2: Hello World: Presentation.

First of all to get all things work properly the only thing you have to KEEP in mind is to: forget advanced coding tools! In other words, until the platform development tools aren’t stable enough, it’s better to type, compile and debug entirely on Edison machine. This isn’t an huge limitation thought.

Edison has great capabilities: it takes advantage of a powerful dual-core Intel® Atom™ 22nm SoC working at 500Mhz, Bluetooth and Wi-Fi feature, all integrated in a size of an SD card.

In addition, The Intel® Edison board includes 1GB of RAM memory, 4GB of eMMC storage and It supports 40 GPIOs with multiple configuration options.

Edison carries all you will need to start! Including Nodejs, Phyton, gcc and so on...

Step 3: Hi Edison!

A part from that, if you’re willing to start approaching to this platform, begin by connecting the Edison with the Arduino breackout board. Wire the board with two USB micro cables into the respective holes and into your computer(the one near the standard USB 2.0 carries power and expose the memory to your computer(you can plug it to any other power supply); the other one is intended only for serial communications via COM). Turn the little switch on the USB side of Breakout Arduino Board in the direction of the micro USB cables to turn on the Edison. Then (Only if you had Windows) downloading this zipped directory to install drivers.

Note that the file here attached represents (Nowadays 15/03/2015) the latest driver version, but for further support download it at the official page at https://software.intel.com/iot/getting-started.

1 After downloading the zipped folder, unzip it and select the voice “Install” from the Context menu which appeared by clicking the right mouse button.

2 Go to StartMenu -> Search -> “DeviceManager” and look for Com Port, note that at this point the Edison would prompt you 3 different Com ports, take a note of the number associated with the plain one.

Step 4: Serial Connection

To communicate via Serial port depending on the operating system you have you:

Windows Download and open the program putty.exe, enter the plain COM port retrieved in the last step(it should look like the one in the image above but the following number will probably change);

Mac ype in the following command ls /dev/tty.*Validate to check if you see something similar to /dev/tty.usbserial-AXXXXXXX;

Linux Build yourself an Edison.

and mind that the frequency is 115200.

Wait until the Edison Board has finished loading all the components and when prompted “user: “ type root and if you haven't previously setup your edison type configure_edison --setup

Enter a name to identify the board

Enter the password for the user root

If you’re interested in getting your board over your existing WiFi network type configure --wifi and when it have retrieved your network select the number associated with it.

For further info look at: https://software.intel.com/en-us/articles/intel-edison-getting-started-wifi

Step 5: Take the Challenge

Before trying to start coding it’s obviously important to focus on choosing the language. Developing over Edison would enable you to get in touch with several different environments to develop your project choose the one you think better and/or fits your needs.

take a look of the image above

Step 6: Let's Code C

C/ C++ sample code

You’re a pro coder: do it by yourself!

Step 7: Let's Code Nodejs

NodeJs Hello world over wifi

var http =require('http');

var server = http.createServer(function(req, res){

res.writeHead(200);

res.end('Hello world, even via HTTP!');

});

server.listen(3000);

Step 8: Let's Code Arduino.ide

Arduino -> go to file -> example. Verify and Load then Enjoy

Help: Ok what didn’t you understand?

Step 9: Would You Like to Spread and Share Your Music Preferences at the Same Time?

Follow the steps in the picture to:

- Install Apache on Yocto;

- Following this steps you will add a nice repository to the almost empty one provided by Intel;

After that continue with the final configuration.

Step 10: Final Step

- Go to etc/apache2/httpd.conf using(cd /etc/apache2/httpd.conf) and modify this lines as follow:

Listen 81

ServerName localhost:81

DocumentRoot

This is made to address the port that would be in conflict with the preinstalled webserver which responds on port 80(default http) when you type your Edison address into your browser. It's used even with the XDK.

- Download our project folder and extract NodeJs files(*.js).

- Connect a led strip to your Edison (by using pins 3, 5, 6);

- We also added a microphone to give user a feedback, which corresponds to a music change. So connect a grove microphone using the groove board (on A1 pin, in the horizontal analog line).

- Once you moved your JS files to the microSD; even making every single file onto the Edison board via vi (Our team suggest you to consider using nano: it’s better. use opkg install nano to get it).

Download our zipped directory for c# windows runtime 8.1 Application. Build and deploy using Visual Studio 2013 Update 2 or upper, making sure you’ve changed references to intel Edison and its daemons including Apache and NodeJs app.

- Connect the Edison Board via WiFi if you haven’t already done it (check with ifconfig if wlan0 is connected, else use configure_edison --wifi to connect it).

- Check that Apache2 is working, if not type systemctl start apache2 in the command prompt of putty.

- Upload to the right place some test files(.wma).

Correct with the position you’ve previously saved( ) files: node nodeFileNames.js .

- Start the windows 8.1 app and press the play button!

- Enjoy J

From Daniele (x2), Alex, David e Francesco

Step 11: Extra Step: Server Code Explaination

The Node.JS file you have downloaded before will create a server listening on the port 4094.

The first time it will recive a request it will save the date&time current timestamp and when another client will connect the server the server will give it the seconds after the song should start from making a simple subtraction.

Here there is the code, just in any case (you may have to add some enter to see it in a decent way):

var interval = 1000;
var net = require('net'); var firstTime = 0; var server = net.createServer(function(c) { //'connection' listener console.log('client connected'); c.on('end', function() { console.log('client disconnected'); }); c.on('data', function(data){ console.log(data.toString()); if(firstTime==0){ var d = new Date(); firstTime = d.getTime(); } var d = new Date(); console.log("hei"); c.write((d.getTime()-firstTime).toString()); }); });

server.listen(4094, function() { //'listening' listener console.log('server bound'); }); server.on('end', function(){ server.end(); });

Step 12: Extra2: Client Code Explaination

Well this code is not as easy to read as the server one.

First of all you will notice that there is an hostname ip address, that is the ip of your Edison. If you don't remember it you can type "ifconfig" inside putty in the linux terminal and it will show under "wlan0".

After that there is an Async procedure that will try to connect on the server port that we have set before (4094), if the call succeed the "datawriter" will sincronize the play.

The best thing you can do with this code is to try it by yourself, Don't copy & paste from the bottom of this page unless the link gets down, the visual studio project is easyer to use and there aren't problems with pre formatting.

Follows the Windows Phone client program main code:

using System;

using System.Collections.Generic; using System.Linq; using System.Text; using Windows.Networking.Sockets; using System.Threading.Tasks; using System.Threading; using System.Net; using Windows.Networking; using Windows.Storage.Streams; using System.Diagnostics;

namespace PhoneApp1 { class SocketClient { private StreamSocket clientSocket;

public async Task Connect() { try{ clientSocket = new StreamSocket(); HostName hostname = new HostName("10.2.1.80"); Debug.WriteLine("Cerco di connettermi"); await clientSocket.ConnectAsync(hostname, "4094"); Debug.WriteLine("Connessione effettuata"); } catch (Exception exception) { switch (SocketError.GetStatus(exception.HResult)) { case SocketErrorStatus.HostNotFound: break; default: break; } } return 10; }

public async Task Send(string data) { DataWriter writer = new DataWriter(clientSocket.OutputStream);

writer.WriteString(data); await writer.StoreAsync(); return 10; }

public async Task Receive() { string data; DataReader reader = new DataReader(clientSocket.InputStream); reader.InputStreamOptions = InputStreamOptions.Partial; var count = await reader.LoadAsync(512); data = reader.ReadString(count); return data; } public void Close() { clientSocket.Dispose(); } } }

Comments

author
ullemiller made it! (author)2015-06-15

cool project - i will try to check it

About This Instructable

1,793views

21favorites

License:

More by david.chieregato:Music party player. DiscoVeryMusic for friends!
Add instructable to: