user12021: I will like to implement a serial communication protocol, using javascript in a mobile browser to make the browser background blink (alternating the color from black to white) according to the bits, to communicate a few bytes to an Arduino using some kind of light sensor (photo diode or resistor) to parse. Electric Imp did something with https://electricimp.com/platform/blinkup/ .
Is there any library or implementation or where to start guide?, if not, how would you implement it? 
I fear one of the problems of using a mobile browser with javascript to light-encode the bits will be timing issues, since setTimeInterval is not perfect, I could split the screen, one half blinking continuously (clock) and the other half the data, but that will require two light sensors.

user2881: Doing bit stuffing can prevent timing problems when you are sending a lot of 0s or 1s in an row. Alternatively use Manchester encoding (slower).
On the browser side, I'd suggest using <Canvas>. Combine this with requestAnimationFrame which gives you a very accurate timestamp as an argument. Though you have to check for support as older browsers don't support that.

12021: <p>I will like to implement a serial communication protocol, using javascript in a mobile browser to make the browser background blink (alternating the color from black to white) according to the bits, to communicate a few bytes to an Arduino using some kind of light sensor (photo diode or resistor) to parse. Electric Imp did something with <a href="https://electricimp.com/platform/blinkup/" rel="nofollow">https://electricimp.com/platform/blinkup/</a> .</p>

<p>Is there any library or implementation or where to start guide?, if not, how would you implement it? </p>

<p>I fear one of the problems of using a mobile browser with javascript to light-encode the bits will be timing issues, since setTimeInterval is not perfect, I could split the screen, one half blinking continuously (clock) and the other half the data, but that will require two light sensors.</p>
 2881: <p>Doing bit stuffing can prevent timing problems when you are sending a lot of <code>0</code>s or <code>1</code>s in an row. Alternatively use Manchester encoding (slower).</p>

<p>On the browser side, I'd suggest using <code>&lt;Canvas&gt;</code>. Combine this with <code>requestAnimationFrame</code> which gives you a very accurate timestamp as an argument. Though you have to check for support as older browsers don't support that.</p>
