Giter Site home page Giter Site logo

node-lego-ir's Introduction

LEGO Infrared

Todo:

  • add PWM control

What it is?

LEGO IR is module that returns an infrared buffer. This can then be used in combination with Tessel to control LEGO Power Functions!

I've only managed to test this on Tessel as it's all I have. If you want any examples adding for other hardware or have tested it on other hardware let me know! (raise an Issue or PR!).

How do I use it?

var LegoIR = require('lego-ir');
var lego = new LegoIR({
  mode: 'comboDirect',
  channel: 1
});

var buffer = lego.move({
  outputA: 'forward',
  outputB: 'float'
});

// Send buffer to Tessel IR and watch your lego move!

Modes

ComboDirect

ComboDirect allows you to control two outputs at once on a single channel.

outputs

  • outputA
  • outputB

Move Options

  • float
  • brake
  • forward
  • backward

Payload Example

lego.move({
  outputA: 'forward',
  outputB: 'float'
});

Examples

Tessel IR

var tessel = require('tessel');
var infraredlib = require('ir-attx4');
var infrared = infraredlib.use(tessel.port['A']);

var LegoIR = require('lego-ir');
var lego = new LegoIR({
  mode: 'comboDirect',
  channel: 1
});

var legoBuffer = lego.move({
  outputA: 'backward',
  outputB: 'forward'
});

infrared.on('ready', function() {
  if(err) throw new Error(err);
  console.log("Connected to IR module!");

  setInterval(function() {
    infrared.sendRawSignal(38, legoBuffer, function(err) {
      if(err) throw new Error(err);
      console.log("IR Signal Sent!");
    });
  }, 500);
});

node-lego-ir's People

Contributors

9khil avatar gitter-badger avatar

Watchers

 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.