How to use the johnny-five.Motor function in johnny-five

To help you get started, we’ve selected a few johnny-five examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github markwest1972 / voice-controlled-zumo / arduino_module / zumo_controller.js View on Github external
board.on("ready", function() {

  // Log
  console.log("Connected to Johnny-Five!");

  // Speed can be anything from 0 to 255
  var SPEED = 130;
  var PAN = 95;
  var TILT = 115;
  var command = "";
  var panState = PAN;
  var tiltState = TILT;

  // Initialise the motors and servos
  var leftMotor = new five.Motor([11, 8]);
  var rightMotor = new five.Motor([5, 7]);
  //var leftMotor = new five.Motor([10, 8]);
  //var rightMotor = new five.Motor([9, 7]);

  var tiltServo = new five.Servo({ pin: 2, range: [ 75, 155 ], startAt: 115 });
  var panServo = new five.Servo({ pin: 4, range: [ 45, 145 ], startAt: 95 });

  // Set up REPL (used mainly for demo and testing purposes)
  board.repl.inject({
    left: leftMotor,
    right: rightMotor,
    tilt: tiltServo,
    pan: panServo
  });

  // Set up MQTT Client
github markwest1972 / voice-controlled-zumo / arduino_module / zumo_controller.js View on Github external
board.on("ready", function() {

  // Log
  console.log("Connected to Johnny-Five!");

  // Speed can be anything from 0 to 255
  var SPEED = 130;
  var PAN = 95;
  var TILT = 115;
  var command = "";
  var panState = PAN;
  var tiltState = TILT;

  // Initialise the motors and servos
  var leftMotor = new five.Motor([11, 8]);
  var rightMotor = new five.Motor([5, 7]);
  //var leftMotor = new five.Motor([10, 8]);
  //var rightMotor = new five.Motor([9, 7]);

  var tiltServo = new five.Servo({ pin: 2, range: [ 75, 155 ], startAt: 115 });
  var panServo = new five.Servo({ pin: 4, range: [ 45, 145 ], startAt: 95 });

  // Set up REPL (used mainly for demo and testing purposes)
  board.repl.inject({
    left: leftMotor,
    right: rightMotor,
    tilt: tiltServo,
    pan: panServo
  });

  // Set up MQTT Client
  //var options = { host: "test.mosca.io", port: "1883" }; //backup
github elementumscm / workshop-roboticsjs / examples / dc_motors / dc_motor.js View on Github external
board.on('ready', function onReady() {
  const motorA = new five.Motor({
      pins: {
        pwm: 6,
        dir: 7,
        cdir: 8
      }
    }),
    motorB = new five.Motor({
      pins: {
        pwm: 11,
        dir: 10,
        cdir: 9
      }
    });

  // 100% velocidad al frente en los dos motores
  motorA.forward(255);
  motorB.forward(255);

  setTimeout(() => {
    // 100% velocidad marcha atras en los dos motores
    motorA.reverse(255);
    motorB.reverse(255);
  }, 5000);
github rwaldron / johnny-five / eg / motor-TB6612FNG.js View on Github external
board.on("ready", () => {
  const spdt = new Switch("a0");
  const throttle = new Sensor("b0");

  // See the comments below for more information about
  // the pins shown in this pin array argument.
  const motor = new Motor([ "a5", "a4", "a3" ]);

  spdt.on("open", () => {
    motor.stop().forward(motor.speed());
  });

  spdt.on("close", () => {
    motor.stop().reverse(motor.speed());
  });

  throttle.on("change", () => {
    motor.speed(throttle.value >> 2);
  });
});
/* @markdown
github Makeblock-official / mbot_nodebots / examples / motors.js View on Github external
board.on("ready", function(err) {

    if (err){
        console.log(err);
        return;
    }
    l_motor = new five.Motor({pins: {pwm: 6, dir: 7}});
    r_motor = new five.Motor({pins: {pwm: 5, dir: 4}});

    console.info("Board connected. Robot set up. LRUD to control");

});
github rodrigo-medeiros / node-school-lessons / nodebot-workshop / spin_motor_spin.js View on Github external
board.on('ready', function () {
  var motor = new five.Motor({
    pin: 9
  });

  motor.on('start', function () {
    board.wait(2000, function () {
      motor.stop();
    });
  });

  motor.on('stop', function () {
    board.wait(1000, function () {
      motor.start(200);
    });
  });

  motor.start(200);
github tableflip / nodebot-workshop / exercises / spin_motor_spin / solution / solution.js View on Github external
board.on('ready', function () {
  var motor = new five.Motor(9)

  motor.on('start', function () {
    board.wait(2000, function () {
      motor.stop()
    })
  })

  motor.on('stop', function () {
    board.wait(1000, function () {
      motor.start(200)
    })
  })

  motor.start(200)
})
github nodebotsau / simplebot / examples / motors.js View on Github external
board.on("ready", function(err) {

    if (err){
        console.log(err);
        return;
    }

    console.info("Board connected. Robot set up");

    motor_r = new five.Motor({
        pins: {
            pwm: 9,
            dir: 8,
        },
        invertPWM: true,
    });

    motor_l = new five.Motor({
        pins: {
            pwm: 6,
            dir: 7,
        },
        invertPWM: true,
    });

    led = new five.Led(11);
github AnnaGerber / little-bits-js / sweep / sweep.js View on Github external
board.on("ready", function() {

  var servo = new five.Motor(5);

  servo.start();

  this.repl.inject({
    servo: servo
  });
  
});
github markwest1972 / voice-controlled-zumo / arduino_module / zumo-controller.js View on Github external
board.on("ready", function() {

  var speed = 125;

  //var piezo = new five.Piezo(3);

  motor1 = new five.Motor([10, 8]);
  motor2 = new five.Motor([9, 7]);

  board.repl.inject({
  	lmotor: motor1,
  	rmotor: motor2,
  });

  require('net').createServer(function (socket) {

     socket.on('data', function (data) {

      switch ( data.toString().trim() ){

        case 'go':
          motor1.rev( speed );
          motor2.rev( speed );
          break;

johnny-five

The JavaScript Robotics and Hardware Programming Framework. Use with: Arduino (all models), Electric Imp, Beagle Bone, Intel Galileo & Edison, Linino One, Pinoccio, pcDuino3, Raspberry Pi, Particle/Spark Core & Photon, Tessel 2, TI Launchpad and more!

MIT
Latest version published 3 years ago

Package Health Score

53 / 100
Full package analysis