How to use the johnny-five.Switch 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 mimming / snippets / gacha-gameception / art.js View on Github external
let config = {};

  servo = new five.Servo({
    pin: 3,
    type: "continuous"
  });

  strip = new pixel.Strip({
    board: this,
    controller: "FIRMATA",
    strips: [{pin: 4, length: 190},],
    gamma: 2.8,
  });

  toggle = new five.Switch(6);

  toggle.on("close", function () {

    if (config['enable-toggle-switch']) {
      // Set to Enlightened
      portalRef.child('faction').set(portalFactionEnum.enlightened.value);
    } else {
      console.log("Toggle switch used when disabled by config");
    }
  });

  toggle.on("open", function () {

    if (config['enable-toggle-switch']) {
      // Set to Resistance
      portalRef.child('faction').set(portalFactionEnum.resistance.value);
github MrYsLab / xi / servers / xiserver / xiserver.js View on Github external
function addSwitch(index, myPin, myId) {
        devices[index] = new five.Switch({
            pin: myPin,
            id: myId
        });

        // event listener call back function for switch going to 'off'
        var switchOffCallbackChange = function () {
            if (debugLevel >= 1) {
                console.log(' switch callback ' + index, devices[index].id + ' off');
            }
            connection.send('dataUpdate/' + devices[index].id + '/' + 0)
        };

        // event listener call back function for switch going to 'on'
        var switchOnCallbackChange = function () {
            if (debugLevel >= 1) {
                console.log(' switch callback ' + index, devices[index].id + ' on');
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);
github mcampo / workshop-domotica / ejercicios / 09_logica_web / hub / door.js View on Github external
board.on('ready', () => {
    let reed = five.Switch(8);

    reed.on('open', () => {
      device.emit('door-open', { timestamp: Date.now() });
    });

    device.emit('ready');
  });
};
github sofroniewn / electron-johnny-five-examples / 2-switch / app / index.js View on Github external
board.on('ready', function() {
  document.getElementById('board-status').src = 'icons/ready.png'
  var led = new five.Led(12)
  var spdt = new five.Switch(9)

  spdt.on('open', function() {
    led.off()
    document.getElementById('led-status').src = 'icons/led-off.png'
  })

  spdt.on('close', function() {
    led.on()
    document.getElementById('led-status').src = 'icons/led-on.png'
  })
})

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