Update syntax in README

This commit is contained in:
Andrew Stewart 2014-11-28 17:47:29 -08:00
parent 2ea9f9503f
commit 45743eb5cb
1 changed files with 32 additions and 18 deletions

View File

@ -48,8 +48,13 @@ var Cylon = require('cylon');
// define the robot // define the robot
var robot = Cylon.robot({ var robot = Cylon.robot({
// change the port to the correct one for your Arduino // change the port to the correct one for your Arduino
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }, connections: {
device: { name: 'led', driver: 'led', pin: 13 }, arduino: { adaptor: 'firmata', port: '/dev/ttyACM0' }
},
devices: {
led: { driver: 'led', pin: 13 }
},
work: function(my) { work: function(my) {
every((1).second(), my.led.toggle); every((1).second(), my.led.toggle);
@ -66,8 +71,13 @@ robot.start();
var Cylon = require('cylon'); var Cylon = require('cylon');
Cylon.robot({ Cylon.robot({
connection: { name: 'ardrone', adaptor: 'ardrone', port: '192.168.1.1' }, connections: {
device: { name: 'drone', driver: 'ardrone' }, ardrone: { adaptor: 'ardrone', port: '192.168.1.1' }
},
devices: {
drone: { driver: 'ardrone' }
},
work: function(my) { work: function(my) {
my.drone.takeoff(); my.drone.takeoff();
@ -132,8 +142,13 @@ bots.forEach(function(bot) {
Cylon.robot({ Cylon.robot({
name: bot.name, name: bot.name,
connection: { name: "sphero", adaptor: "sphero", port: bot.port }, connections: {
device: { name: "sphero", driver: "sphero" }, sphero: { adaptor: "sphero", port: bot.port }
},
devices: {
sphero: { driver: "sphero" }
},
work: function(my) { work: function(my) {
every((1).second(), function() { every((1).second(), function() {
@ -156,20 +171,19 @@ libraries, Cylon.JS also supports a fluent syntax:
```javascript ```javascript
var cylon = require('cylon'); var Cylon = require('cylon');
cylon.robot({ Cylon
connection: { name: 'arduino', adaptor: 'firmata', port: '/dev/ttyACM0' }, .robot()
device: { name: 'led', driver: 'led', pin: 13 } .connection('arduino', { adaptor: 'firmata', port: '/dev/ttyACM0' })
}) .device('led', { driver: 'led', pin: 13 })
.on('ready', function(bot) {
.on('ready', function(bot) {
setInterval(function() { setInterval(function() {
bot.led.toggle(); bot.led.toggle();
}, 1000); }, 1000);
}) });
.start(); Cylon.start();
``` ```
## Hardware Support ## Hardware Support