GithubHelp home page GithubHelp logo

shieldbot.js's Introduction

shieldbot.js

Control Shieldbot with JavaScript

Shieldbot

API

Shieldbot - Constructor

Must be done inside board ready

var five = require("johnny-five");
var Shieldbot = require('shieldbot');

var board = new five.Board();

board.on("ready", function(){

  var shieldbot = new Shieldbot();

});

wait - Delay execution of next task

Returns a promise that is resolved after specified duration

// delay for 1000 milliseconds
shieldbot.wait(1000).then(function(){
  // do something after delay
});

motor - Turn a motor at a specified magnitude

Typically used internally

// magnitude can be between -128 & 127
shieldbot.motor('leftPins', 127);
shieldbot.motor('rightPins', 127);

leftMotor - Turn the left motor at specified magnitude

Typically used internally

// magnitude can be between -128 & 127
shieldbot.leftMotor(127);

rightMotor - Turn the right motor at specified magnitude

Typically used internally

// magnitude can be between -128 & 127
shieldbot.rightMotor(127);

forward - Drive forward

Given a speed and duration, drives the bot forward

Returns a promise that is resolved after specified duration

shieldbot.forward(127, 4800);

reverse - Drive in reverse

Given a speed and duration, drives the bot backward

Returns a promise that is resolved after specified duration

shieldbot.reverse(127, 4800);

stop - Stop

Stops the bot

Returns a resolved promised

shieldbot.stop();

fastStopSide - Disables motor on given side

Typically used internally

shieldbot.fastStopSide('leftPins');
shieldbot.fastStopSide('rightPins');

fastStop - Disables both motors

You should probably be using stop

shieldbot.fastStop();

turnLeft - Turn left

Given a speed and duration, turns the bot left

Returns a promise that is resolved after specified duration

shieldbot.turnLeft(127, 1000);

turnRight - Turn right

Given a speed and duration, turns the bot right

Returns a promise that is resolved after specified duration

shieldbot.turnRight(127, 1000);

Line Following

The Shieldbot also has finders on the front (good for line following)

We emit events when the finder values change

finder.on & finder.off - Emitted when the finder changes state to on or off

Callbacks receive the pin number that changed

shieldbot.on('finder.on', function(pin){
  console.log('on', pin);
});

shieldbot.on('finder.off', function(pin){
  console.log('off', pin);
});

shieldbot.js's People

Contributors

jacobrosenthal avatar phated avatar ohcolinho 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.