Skip to content

Instantly share code, notes, and snippets.

@jaredmoody
Created November 19, 2012 03:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jaredmoody/4108769 to your computer and use it in GitHub Desktop.
Save jaredmoody/4108769 to your computer and use it in GitHub Desktop.
Electric Imp Reed Sensor
// Reed Sensor
function changed()
{
local result = hardware.pin1.read();
server.show(result?"On":"Off");
hardware.pin9.write(result);
}
// configure pin 1 as digital input
hardware.pin1.configure(DIGITAL_IN_PULLUP, changed);
// Configure pin 9 as an open drain output with internal pull up
hardware.pin9.configure(DIGITAL_OUT_OD_PULLUP);
// Register with the server
imp.configure("Reed Sensor", [], []);
server.show("Reed sensor");
changed();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment