Breadboard for "Switch - Tilt SW-200D"

switch-tilt-SW_200D.png

Fritzing diagram: 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");
  });
});

 

Component Classes in this example:

Hi! The Johnny-Five community is building new projects every day. We made this newsletter to tell you about what's new, what's good, and what's next for Open Source robotics. Join us in exploring what we can make together.

Fork me on GitHub