Skip to content

Latest commit

 

History

History
71 lines (35 loc) · 1.11 KB

switch-tilt-SW_200D.md

File metadata and controls

71 lines (35 loc) · 1.11 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
const {Board, Button} = require("johnny-five");
const board = new Board();

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

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

  // tilt the breadboard to the right, towards to the ground pin
  tilt.on("down", () => console.log("down"));

  // tilt and hold
  tilt.on("hold", () => console.log("hold"));

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

 

License

Copyright (c) 2012-2014 Rick Waldron [email protected] Licensed under the MIT license. Copyright (c) 2015-2023 The Johnny-Five Contributors Licensed under the MIT license.