Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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