Skip to content

Instantly share code, notes, and snippets.

@dexterlabora
dexterlabora / trafficsignal.js
Created Sep 17, 2015
IoL - Traffic Signal - LED Sequence
View trafficsignal.js
//trafficsignal.js
var five = require("johnny-five");
var board = new five.Board();
//Arduino board connection
board.on("ready", function() {
@dexterlabora
dexterlabora / trackswitch.js
Created Sep 17, 2015
IoL - Lego Track Switch - Servo and LEDs
View trackswitch.js
//trackswitch.js
var five = require("johnny-five");
var board = new five.Board();
//Arduino board connection
board.on("ready", function() {
View traincrossing.js
// traincrossing.js
// Dependencies
var five = require("johnny-five");
var board = new five.Board();
// Arduino board connection
board.on("ready", function() {
// Train Crossing Components
@dexterlabora
dexterlabora / energysave.js
Created Sep 21, 2015
Save energy by detecting motion to turn on lights and then turning them off after 5 minutes of inactivity.
View energysave.js
// energysave.js
// www.internetoflego.com
// Dependencies
var five = require("johnny-five");
var board = new five.Board();
// Arduino board connection
board.on("ready", function() {
@dexterlabora
dexterlabora / elevator.js
Created Sep 26, 2015
Operate an elevator with a web API using a 5v motor and an ultrasonic sensor for positioning.
View elevator.js
// elevator.js
// This program will use an Adafruit motor shield v1 (http://www.adafruit.com/products/81) clone to power a small 5v motor
// and an ultrasonic sensor for positioning
// The ultrasonic sensor requires PingFirmata on the Arduino (http://johnny-five.io/api/proximity/#pingfirmata)
// Dependencies
var five = require('johnny-five');
var board = new five.Board();
@dexterlabora
dexterlabora / server.js
Last active Sep 28, 2015
Server to provide a web API and socket interface for controlling Arduino circuits.
View server.js
// server.js
// This program creates the server for controlling Arduino or similar projects.
// You can either use a web socket for real-time communication, or GET requests to send commands easily.
// Refer to the following "elevator.js" file for a working circuit file that accepts the commands.
// https://gist.github.com/dexterlabora/4a4692d0954eab107dd2
// More info at www.internetoflego.com
// includes
var Primus = require('primus');
@dexterlabora
dexterlabora / citystation.js
Last active Oct 6, 2015
This NodeJS program uses the Linux LIRC driver to control Lego infrared Power Functions
View citystation.js
// citystation.js
// Dependencies
var five = require('johnny-five');
var raspi = require("raspi-io");
var board = new five.Board({
io: new raspi()
});
View server-pubnub.js
// server-pubnub.js
// www.InternetOfLego.com
// This app provides a multi-functional server for which a "circuit file" is spawned from the process.
// Child process communication example: circuit.send({'command': 'led_on'});
// The server provides support for the following communication options
// RESTful API using express example: http://192.168.0.15:8080/command/led_on)
// Websocket using Primus example: spark.send('command', 'led_on')
// Messaging using PubNub example: pubnub.publish({channel :'iol', message : {"command":"led_on"}})
View circuit-master.js
// circuit-master.js
// This program uses multiple microcontrollers in the same app to control a living Lego city.
// ~~ IoL City ~~
// www.InternetOfLego.com
// ~~~~ CIRCUIT ~~~~~~~
// Includes
var five = require('johnny-five');
var Raspi = require("raspi-io");
View traintrackswitch.js
// traintrackswitch.js
/****************************
// Lego Train Track Switch
// This app uses the Johnny-Five.io framework to control a servo and lights
// The servo will switch the track to the desired location and update the direction lights
// Commands can be sent from the "iol" PubNub channel
// {"command":"track_straight"}
// {"command":"track_turn"}
// {"command":"track_toggle"}