|
11 | 11 | ThingerWifi thing(USERNAME, DEVICE_ID, DEVICE_CREDENTIAL); |
12 | 12 |
|
13 | 13 | void setup() { |
14 | | - // set the boards led to output |
15 | | - pinMode(RED_LED, OUTPUT); |
16 | | - pinMode(GREEN_LED, OUTPUT); |
17 | | - pinMode(YELLOW_LED, OUTPUT); |
18 | | - |
19 | | - // configure wifi network |
20 | | - thing.add_wifi(SSID, SSID_PASSWORD); |
21 | | - |
22 | | - // resource input example (i.e. turning on/off a light, a relay, configuring a parameter, etc) |
23 | | - thing["led"]["green"] << [](pson& in){ digitalWrite(GREEN_LED, in ? HIGH : LOW); }; |
24 | | - thing["led"]["yellow"] << [](pson& in){ digitalWrite(YELLOW_LED, in ? HIGH : LOW); }; |
25 | | - thing["led"]["red"] << [](pson& in){ digitalWrite(RED_LED, in ? HIGH : LOW); }; |
26 | | - |
27 | | - // resource output example (i.e. reading a sensor value) |
28 | | - thing["millis"] >> [](pson& out){ out = millis(); }; |
29 | | - |
30 | | - // resource input/output example (i.e. passing input values and do some calculations) |
31 | | - thing["in_out"] = [](pson& in, pson& out){ |
32 | | - out["sum"] = (long)in["value1"] + (long)in["value2"]; |
33 | | - out["mult"] = (long)in["value1"] * (long)in["value2"]; |
34 | | - }; |
| 14 | + // set the boards led to output |
| 15 | + pinMode(RED_LED, OUTPUT); |
| 16 | + pinMode(GREEN_LED, OUTPUT); |
| 17 | + pinMode(YELLOW_LED, OUTPUT); |
| 18 | + |
| 19 | + // configure wifi network |
| 20 | + thing.add_wifi(SSID, SSID_PASSWORD); |
| 21 | + |
| 22 | + // pin control example (i.e. turning on/off a light, a relay, etc) |
| 23 | + thing["led"]["green"] << digitalPin(GREEN_LED); |
| 24 | + thing["led"]["yellow"] << digitalPin(YELLOW_LED); |
| 25 | + thing["led"]["red"] << digitalPin(RED_LED); |
| 26 | + |
| 27 | + // resource output example (i.e. reading a sensor value, a variable, etc) |
| 28 | + thing["millis"] >> outputValue(millis()); |
| 29 | + |
| 30 | + // more details at http://docs.thinger.io/arduino/ |
35 | 31 | } |
36 | 32 |
|
37 | 33 | void loop() { |
|
0 commit comments