Back to Johnny Five

Switch - Magnetic Door

docs/switch-magnetic-door.md

2.1.01022 B
Original Source
<!--remove-start-->

Switch - Magnetic Door

<!--remove-end-->
Breadboard for "Switch - Magnetic Door"

Fritzing diagram: docs/breadboard/switch-magnetic-door.fzz

 

Run this example from the command line with:

bash
node eg/switch-magnetic-door.js
javascript
const {Board, Switch} = require("johnny-five");
const board = new Board();

board.on("ready", () => {
  // Contact Mode: Normally Open (default!)
  const sw = new Switch(7);
  sw.on("open", () => console.log("open"));
  sw.on("close", () => console.log("close"));
});

Learn More

 

<!--remove-start-->

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.

<!--remove-end-->