GithubHelp home page GithubHelp logo

imclab / sparky-2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from kevingrandon/sparky

0.0 2.0 0.0 8.54 MB

Sparky is a node.js micro-library for controlling the sparkcore.

License: Mozilla Public License 2.0

JavaScript 84.41% Arduino 15.59%

sparky-2's Introduction

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
});

sparky-2's People

Contributors

hexalyse avatar kevingrandon avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.