Last active
          August 29, 2015 13:57 
        
      - 
      
- 
        Save bwhite/9656448 to your computer and use it in GitHub Desktop. 
    [wearscript] Arduino Power Tail
  
        
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | #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()); | |
| } | |
| } | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | <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> | 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | {"name":"Arduino Power Tail"} | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment