1

A friend of mine & I made an RGB Strip with the help of Arduino and Java. The apparatus is connected to the PC via USB & the code calculates the average RGB values on the PC screen & that glows the strip accordingly.

What I want to try is-

I have a Windows Phone. I want to use it instead of the RGB Strip so that the phone screen gives the average color o/p.

  1. How do I start with it? how can I make my phone to communicate with my PC via USB so that it receives the input with a good refresh rate?

  2. What namespaces should I use to program it in C# ?

Cole Tobin
  • 9,206
  • 15
  • 49
  • 74
Siddharth Thevaril
  • 3,722
  • 3
  • 35
  • 71
  • What have you tried. Do you know how to detect this information via code, it seems like, you don't which will be a major wall for you. – Security Hound Jul 16 '12 at 17:56
  • I have tried the Java code for Arduino, the main issue is how to receive PC o/p as Phone i/p. Once I know that the rest I may be able to code in C# – Siddharth Thevaril Jul 17 '12 at 06:42

1 Answers1

5

Windows Phone abstracts the USB port as an Ethernet connection so you can create IP connections to a virtual adapter (See Send data from WP7 phone to PC via USB cable ) so all you need to do is write a server program that runs on your computer and a client on the device (I don't recommend doing it the other way around). The server then sends the colour information to the client and your program then sets the phone's screen colour accordingly.

Networking classes are contained in the System.Net namespace, but you may end up using IO classes in System.IO.

The purist in me wants to recommend using Socket classes directly, but I find the NetworkStream class easier to use with as it conforms to .NET's conventions for bidirectional streams (and beats having to manage buffers yourself).

Community
  • 1
  • 1
Dai
  • 141,631
  • 28
  • 261
  • 374
  • 1
    +1. As a little addition to the answer @Sidsec9: Windows Phone does not support server sockets, thats why you *have* to implement the TCP/UDP server on your PC and connect to it from the phone. When the connection is established you can send your color values from the PC back to the phone periodically. You can then also use WiFi instead of needing the USB cable if you want. – Philip Daubmeier Jul 16 '12 at 23:08
  • Sir can you tell me from where to start & a small sample code to establish such connection between the phone and the PC? The rest of the coding I may be able to do it on my own. – Siddharth Thevaril Jul 17 '12 at 06:40