This week’s project, webaudio-serial-tx, let’s your phone (or any computer with a headphone jack) transmit serial data to hardware like an Arduino.
Bottomline: you can control physical things / servos / motors / hardware from your phone, using just the browser. Super useful for hackathon hackers.
Here’s an example of a phone controlled servo from author James Halliday:
Next, it uses the WebAudio API to create an output buffer, mapping Os &s 1s into voltages between -1 & 1, which are output via the headphone jack.
Everything is packaged up super nicely, so you can send data in a few lines of code:
port.write(new Buffer(5000).fill(‘Hi There!’)); port.start(); ```
If you browserify that script & run it in Chrome, you’ll hear some digital noise coming out of your speakers—but trust me, your Arduino (with a few extra caps & resistors) will totally grok it.