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
<?xml version="1.0"?> | |
<configuration> | |
<system.web> | |
<compilation debug="true" targetFramework="4.0" /> | |
<customErrors mode="Off" /> | |
<httpHandlers> | |
<add verb="*" type="Nancy.Hosting.Aspnet.NancyHttpRequestHandler" path="*"/> | |
</httpHandlers> | |
</system.web> |
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
// This line of code will be shown in the planner to help identify what the code module does. | |
imp.configure("first program", [], []); | |
server.show("Hello from beardedinventor!"); |
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
// Everyone loves blinking LEDs, now you can too | |
local ledState = 0; | |
function blink() | |
{ | |
if (ledState == 1) | |
ledState = 0; | |
else | |
ledState = 1; |
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
// Register with the server | |
imp.configure("Press button to read", [], []); | |
// readButton function called every 100ms | |
function changeState() | |
{ | |
local pinState = hardware.pin1.read(); | |
if (pinState) | |
{ | |
local sensorValue = hardware.pin2.read(); |
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) |
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
local redPot = hardware.pin5; | |
local greenPot = hardware.pin7; | |
local bluePot = hardware.pin8; | |
local red = 0; | |
local green = 0; | |
local blue = 0; | |
local redPort = OutputPort("red"); | |
local greenPort = OutputPort("green"); |
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
imp.configure("Analog In", [], []); | |
function readPots() | |
{ | |
local p = hardware.pin5.read(); | |
server.show(p); | |
imp.wakeup(0.5, readPots); | |
} | |
hardware.pin5.configure(ANALOG_IN); |
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
// This is the function that actually handles the incoming HTTP Request | |
function SimpleRequestHandler(data) { | |
server.log("Got a request with value='" + data + "'"); | |
return 200; | |
} | |
// handles incoming HttpIn requests, and sends "responses" to an HttpRequest node through | |
// an output port. The ResponsePort sends a url-encoded message where "value" is the response code. | |
class HttpInPortWithResponse extends InputPort { | |
RequestHandler = null; // function that will be called whenever a request comes into the input port. Should return a status code. |
OlderNewer