0.1.1 • Published 10 years ago

sparky v0.1.1

Weekly downloads
7
License
-
Repository
github
Last release
10 years ago

Sparky

Sparky is a simple node.js library for communicating with a Spark core. Sparky wraps the four default methods (analogRead, analogWrite, digitalRead, digitalWrite), and has a run method for any custom firmware methods on your SparkCore.

Installation

npm install sparky

Usage

Turn the built-in LED on.

var Sparky = require('sparky')

var core1 = new Sparky({
	deviceId: 'your device id',
	token: 'your access token',
})
core1.digitalWrite('D7', 'HIGH');

Blinking the built-in LED.

var Sparky = require('sparky')

var core1 = new Sparky(config);
var val = 0;
(function toggle() {
	val = 1 - val;
	core1.digitalWrite('D7', val);
	setTimeout(toggle, 1000);
})();

Run a custom command from your SparkCore firmware.

var Sparky = require('sparky')

var core1 = new Sparky({
	deviceId: 'your device id',
	token: 'your access token',
})
core1.run('MyCustomFunction', 'what,ever,you,want', callback);

Read a variable from your SparkCore. See the examples/read_var code for an example sketch.

var Sparky = require('sparky')

var core1 = new Sparky({
	deviceId: 'your device id',
	token: 'your access token',
})

core1.get('MyCustomVariable', function(response) {
	// Full response of the SparkCore API resides in the first argument
});
0.1.1

10 years ago

0.1.0

10 years ago

0.0.14

10 years ago

0.0.13

10 years ago

0.0.12

10 years ago

0.0.11

10 years ago

0.0.10

10 years ago

0.0.9

10 years ago

0.0.8

10 years ago

0.0.7

10 years ago

0.0.5

10 years ago

0.0.4

10 years ago

0.0.2

10 years ago

0.0.1

10 years ago