Skip to content

Instantly share code, notes, and snippets.

@bwhite
Last active August 29, 2015 13:57
Show Gist options
  • Save bwhite/9656448 to your computer and use it in GitHub Desktop.
Save bwhite/9656448 to your computer and use it in GitHub Desktop.
[wearscript] Arduino Power Tail
#include <SoftwareSerial.h>
SoftwareSerial mySerial(3, 2); // RX, TX
void setup()
{
Serial.begin(57600);
while (!Serial) {
}
mySerial.begin(9600);
pinMode(4, OUTPUT);
}
void loop()
{
if (mySerial.available()) {
char c = mySerial.read();
if (c == '0')
digitalWrite(4, 0);
else
digitalWrite(4, 1);
Serial.write(c);
}
if (Serial.available()) {
delay(10); // HACK
mySerial.write(Serial.read());
}
}
<html style="width:100%; height:100%; overflow:hidden">
<body style="width:100%; height:100%; overflow:hidden; margin:0">
<script>
function main() {
if (WS.scriptVersion(1)) return;
var addr = '00:00:12:06:57:19';
WS.bluetoothList(function (x) {
WS.log(JSON.stringify(x));
setTimeout(function () {WS.bluetoothWrite(addr, '0')}, 2000);
});
WS.gestureCallback('onGestureSWIPE_LEFT', function () {
WS.bluetoothWrite(addr, '0');
});
WS.gestureCallback('onGestureSWIPE_RIGHT', function () {
WS.bluetoothWrite(addr, '1');
});
}
window.onload = main;
</script>
</body>
</html>
{"name":"Arduino Power Tail"}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment