Skip to content

Commit

Permalink
Current nice working version
Browse files Browse the repository at this point in the history
  • Loading branch information
sbstjn committed Mar 5, 2012
1 parent 49b41cd commit 35fe330
Show file tree
Hide file tree
Showing 47 changed files with 967 additions and 660 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Welcome
96 changes: 0 additions & 96 deletions app-old.js

This file was deleted.

96 changes: 0 additions & 96 deletions app.js

This file was deleted.

76 changes: 24 additions & 52 deletions examples.snippet
Original file line number Diff line number Diff line change
Expand Up @@ -8,68 +8,40 @@ crw-rw-rw- 1 root wheel 18, 16 24 Feb 22:00 tty.usbmodem1d11
> node app.js
Listening on http://localhost:8080

###toggleLED
require(['libs/Noduino', 'libs/Noduino.Socket'], function(NoduinoObj, Connector) {
var Noduino = new NoduinoObj({debug: true, host: 'http://localhost:8090'}, Connector);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
board.withLED({pin: 13}, function(err, LED) {
if (err) { return console.log(err); }

LED.blink(250);
LED.on('change', function() }
console.log('LED changed to ' + (data.mode == Noduino.HIGH ? '[on]' : '[off]'));
});
});
})
});

###connect
require(['libs/Noduino', 'libs/Noduino.Socket'], function(NoduinoObj, Connector) {
var Noduino = new NoduinoObj({debug: true, host: 'http://localhost:8090'}, Connector);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
var Noduino = new NoduinoObj({debug: true, host: 'http://localhost:8090'}, Connector);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }

console.log('Connected to board');
});
console.log('Connected to board');
});

###listenButton
var Noduino = new require('./libs/Noduino')({'debug': true});
Noduino.connect({'type': 'socket'}, function(err, board) {
###toggleLED
var Noduino = new NoduinoObj({debug: true, host: 'http://localhost:8090'}, Connector);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
board.withButton({pin: 9}, function(err, Button)) {
Button.on(cnst.HIGH, function(mode) {
console.log('pushed!');
});

Button.on(cnst.LOW, function(mode) {
console.log('released!');
board.withLED({pin: 13}, function(err, LED) {
if (err) { return console.log(err); }

LED.blink(250);
LED.on('on', function() }
console.log('LED is on!');
});
})
});
});

###analogRead
noduino.connect(function(err, board) {
if (err) { return console.log('failed to connect!'); }

console.log('connected');
});
###listenButton
var Noduino = new NoduinoObj({debug: true, host: 'http://localhost:8090'}, Connector);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }
board.withButton({pin: 13}, function(err, Button) {
if (err) { return console.log(err); }

###digitalRead
noduino.connect(function(err, board) {
board.registerPin({pin: 9}, function(err, pin) {
pin.digitalRead(function(err, value) {
console.log('received value: ' + value);
Button.on('push', function() }
console.log('Button pushed');
});

Button.push();
});
});

###digitalWrite
noduino.connect(function(err, board) {
board.registerPin({pin: 9}, function(err, pin) {
pin.digitalWrite(const.HIGH, function(err, value) {
console.log('set pin to value: ' + value);
});
})
});
21 changes: 0 additions & 21 deletions examples/http_analogled.js

This file was deleted.

26 changes: 0 additions & 26 deletions examples/http_ledonoff.js

This file was deleted.

18 changes: 18 additions & 0 deletions examples/test.blinkLED.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
var requirejs = require('requirejs');
requirejs.config({nodeRequire: require});

requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '../public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {
var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }

board.withLED({pin: 12}, function(err, LED) {
if (err) { return console.log(err); }

LED.blink(250);
LED.on('on', function(e) {
console.log('LED is on!');
});
});
});
});
15 changes: 15 additions & 0 deletions examples/test.readAnalogIn.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
var requirejs = require('requirejs');
requirejs.config({nodeRequire: require});

requirejs(['../public/scripts/libs/Noduino', '../public/scripts/libs/Noduino.Serial', '../public/scripts/libs/Logger'], function (NoduinoObj, NoduinoConnector, Logger) {
var Noduino = new NoduinoObj({'debug': false}, NoduinoConnector, Logger);
Noduino.connect(function(err, board) {
if (err) { return console.log(err); }

board.withAnalogInput({pin: 'A0'}, function(err, AnalogInput) {
AnalogInput.on('change', function(a) {
console.log('read value: ' + a.value);
});
});
});
});
Loading

0 comments on commit 35fe330

Please sign in to comment.