How to use the johnny-five.Servo 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 rachelnicole / robokitty / lib / device.js View on Github external
board.on('ready', function() {

      var servo = new five.Servo({
        pin: 'd0',
        type: 'continuous',
        deadband: [ 95, 96 ]
      });

      servo.stop();

      io.sockets.on('connection', function (socket) {
        console.log('sockets on connection');

        socket.emit('setSchedule', currentTimeValue);

        socket.on('click', function () {
          console.log('socket is on');

          // have servo turn counter clockwise incase any food is stuck before turning clockwise to dispense
github rwaldron / particle-io / eg / servo.js View on Github external
board.on("ready", function() {
  console.log("CONNECTED");

  // Create a new `servo` hardware instance.
  var servo  = new five.Servo("D0");

  temporal.queue([
    {
      delay: 0,
      task: function(){
        // min()
        //
        // set the servo to the minimum degrees
        // defaults to 0
        //
        servo.min();
      }
    },{
      delay: 1000,
      task: function(){
        // max()
github intel / intel-iot-services-orchestration-layer / node_modules / hope-demo / lattepanda / init.js View on Github external
function stopServo(params){
  
  // parse params, params[0] should be "set_digital"
  var pinNumber = params[1];
  
  var servo = servos[pinNumber];
  
  if (servo == null) {
    log("creating new servo " + pinNumber);
    try{
      servo = new five.Servo(pinNumber);
      servos[pinNumber] = servo;
      
    } catch (err) {
      dir(err);
      log(err.stack.split("\n"));
      
    }
  }

  log("servoNumber %d stop", pinNumber);

  servo.stop();

  pinWrites[pinNumber].mode = MODE_SERVO;
  pinReads[pinNumber] = servo.value;
github GabeWeiss / google-sorting-demo / lenovo / simple.js View on Github external
board.on("ready", function() {
     servo = five.Servo({
         pin: 9,
         startAt: 90,
         range: [0, 180],
         interval: 10
     });
     servo.sweep([45,135]);
     servo2 = five.Servo({
         pin: 10,
         startAt: 90,
         range: [0, 180],
         interval: 10
     });
     servo2.sweep([135,45]);
     // servo.to(50);
     // left();
});
github mimming / snippets / nodebotyay / servo.js View on Github external
board.on("ready", function() {

  button = new five.Button(8);
  var led = new five.Led(7);
  var servo = new five.Servo(10);
  

  board.repl.inject({
    button: button,
    led: led,
    servo: servo    
  });

  button.on("down", function() {
    console.log("down");
    led.on();
    servo.min();
  });

  button.on("up", function() {
    console.log("up");
github sofroniewn / electron-johnny-five-examples / 3-servo / app / index.js View on Github external
board.on('ready', function() {
  document.getElementById('board-status').src = 'icons/ready.png'
  input.className = 'input'
  input.readOnly = false
  var servo = new five.Servo({pin: 10, startAt: 90, range: [45, 135]});
  horn(position-90, '#505050')

  input.addEventListener('change', function () {
    var str = input.value
    if (!isNaN(Number(str))) {
      position = Number(str)
    }
    else if (str.charCodeAt(str.length-1) === 176){
      if (!isNaN(Number(str.substring(0,str.length-1)))) {
        console.log('number + degree')
        position = Number(str.substring(0,str.length-1))
      }
    }
    if (position < 45) position = 45
    if (position > 135) position = 135
    position = Math.round(position)
github octoblu / dynamic-j5 / main.js View on Github external
break;
            case "analogRead":

              board.pinMode(payload.pin, five.Pin.ANALOG);
              board.analogRead(payload.pin, function(value) {
                if(_.has(component, payload.name)){
                read[payload.name] = value;
                }
              });
              break;
            case "analogWrite":
              board.pinMode(payload.pin, five.Pin.PWM);
              names.push(payload.name);
              break;
            case "servo":
              servo[payload.name] = new five.Servo({
                pin: payload.pin,
              });
              names.push(payload.name);
              break;
            case "PCA9685-Servo":
              servo[payload.name] = new five.Servo({
                address: 0x40,
                controller: "PCA9685",
                pin: payload.pin,
              });
              names.push(payload.name);
            case "oled-i2c":
                  debug("oledddoo");
                  var opts = {
                        width: 128,
                        height: 64,
github rockbot / artbot / artbot.js View on Github external
board.on('ready', function () {

    var led = new five.Led(13);
    led.off();

    lServo = new five.Servo({
      pin: 11,
      type: 'continuous'
    });

    rServo = new five.Servo({
      pin: 10,
      type: 'continuous'
    });

    marker = new five.Servo({
      pin: 9
    });

    moves.stop();
    marker.center();
github rwaldron / johnny-five / eg / arduino-starter-kit / knock-lock.js View on Github external
var piezo = new five.Sensor({
    pin: "A0",
    threshold: 10
  });
  piezo.on("change", function() {
    box.knock(this.value);
  });
  var button = new five.Button(2);
  button.on("press", function() {
    box.lock();
  });

  var yellow = new five.Led(3);
  var green = new five.Led(4);
  var red = new five.Led(5);
  var servo = new five.Servo(9);
  var box = new Box(servo, red, green, yellow);
});
github tapsterbot / tapsterbot / software / src / bot.js View on Github external
range: [35, 145] //Too high of a minimum input will cause issues with the forward kinematics
    });
    servo2 = five.Servo({
        address: 0x40,
        controller: "PCA9685",
        pin: 1,
        range: [35, 145]
    });
    servo3 = five.Servo({
        address: 0x40,
        controller: "PCA9685",
        pin: 2,
        range: [35, 145]
    }); */

  servo1 = five.Servo({
      pin: 9,
      range: [0, 100]
  });

  servo2 = five.Servo({
      pin: 10,
      range: [0, 100]
  });

  servo3 = five.Servo({
      pin: 11,
      range: [0, 100]
  });

    board.repl.inject({
      servo1: servo1,

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

56 / 100
Full package analysis