Created
February 19, 2015 20:29
-
-
Save deadprogram/417a65ef45d647def5a3 to your computer and use it in GitHub Desktop.
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
| "use strict"; | |
| var Cylon = require("cylon"); | |
| Cylon.api("http", {host: "0.0.0.0", ssl: false}); | |
| var Green = 0x0000FF, | |
| Red = 0xFF0000; | |
| var bots = { | |
| "luke": "cc360e85785e", | |
| "biggs": "d7995a26ec38", | |
| "wedge": "cf5722dd186e" | |
| }; | |
| Object.keys(bots).forEach(function(name) { | |
| var uid = bots[name]; | |
| Cylon.robot({ | |
| name: name, | |
| connections: { | |
| bluetooth: { adaptor: 'central', uuid: uid, module: 'cylon-ble'} | |
| }, | |
| devices: { | |
| ollie: { name: 'ollie', driver: 'ollie'} | |
| }, | |
| move: function(direction) { | |
| var my = this; | |
| switch (direction) { | |
| case "up": | |
| my.ollie.roll(60, 0, 1); | |
| break; | |
| case "down": | |
| my.ollie.roll(60, 180, 1); | |
| break; | |
| case "left": | |
| my.ollie.setRGB(0xFF0000, false, function() { | |
| my.ollie.setRawMotorValues(my.ollie.MotorForward, 200, my.ollie.MotorReverse, 200); | |
| }); | |
| break; | |
| case "right": | |
| my.ollie.setRGB(0xFF0000, false, function() { | |
| my.ollie.setRawMotorValues(my.ollie.MotorReverse, 200, my.ollie.MotorForward, 200); | |
| }); | |
| } | |
| setTimeout(function() { | |
| my.ollie.setRGB(0x00FFFF, false, function() { | |
| my.ollie.stop(); | |
| }); | |
| }, 500); | |
| return "ok"; | |
| }, | |
| commands: function() { | |
| return { | |
| move: this.move | |
| }; | |
| }, | |
| work: function(my) { | |
| my.ollie.wake(function(err, data){ | |
| after(200, function() { | |
| my.ollie.setRGB(0x00FFFF); | |
| }); | |
| }); | |
| } | |
| }); | |
| }); | |
| Cylon.start(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment