Permalink
Fetching contributors…
Cannot retrieve contributors at this time
79 lines (42 sloc) 1.16 KB

Switch - Tilt SW-200D

Breadboard for "Switch - Tilt SW-200D"

docs/breadboard/switch-tilt-SW_200D.png

Fritzing diagram: docs/breadboard/switch-tilt-SW_200D.fzz

 

Run this example from the command line with:

node eg/switch-tilt-SW_200D.js
var five = require("johnny-five");
var board = new five.Board();
var tilt;

board.on("ready", function() {
  tilt = new five.Button(2); // digital pin 2

  board.repl.inject({
    button: tilt
  });

  // tilt the breadboard to the right, towards to the ground pin
  tilt.on("down", function() {
    console.log("down");
  });

  // tilt and hold
  tilt.on("hold", function() {
    console.log("hold");
  });

  // tilt back the breadboard to the stable position
  tilt.on("up", function() {
    console.log("up");
  });
});

 

License

Copyright (c) 2012-2014 Rick Waldron waldron.rick@gmail.com Licensed under the MIT license. Copyright (c) 2015-2018 The Johnny-Five Contributors Licensed under the MIT license.