Last active
December 14, 2015 00:49
-
-
Save cat-haines/5001865 to your computer and use it in GitHub Desktop.
ElectricImp code for setting an LED based on value from an InputPort
This file contains 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
class simpleInputPort extends InputPort | |
{ | |
function set(value) | |
{ | |
if (value == 1) | |
{ | |
server.show("on"); | |
hardware.pin2.write(0); | |
} | |
else if (value == 0) | |
{ | |
server.show("off"); | |
hardware.pin2.write(1); | |
} | |
else | |
{ | |
server.show("error"); | |
} | |
} | |
}; | |
hardware.pin2.configure(DIGITAL_OUT_OD_PULLUP); | |
local p = simpleInputPort(); | |
imp.configure("Simple Input Port", [simpleInputPort], []); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment