Created
November 19, 2012 03:18
-
-
Save jaredmoody/4108769 to your computer and use it in GitHub Desktop.
Electric Imp Reed Sensor
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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