Skip to content

Instantly share code, notes, and snippets.

@cat-haines
Last active December 14, 2015 00:49
Show Gist options
  • Save cat-haines/5001865 to your computer and use it in GitHub Desktop.
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
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