|
| 1 | +#include "arduino_secrets.h" |
| 2 | +/* |
| 3 | + Sketch generated by the Arduino IoT Cloud Thing "Test_MultiValue" |
| 4 | + https://create-dev.arduino.cc/cloud/things/06012290-ec85-4f5c-aa00-81c0525efa0c |
| 5 | +
|
| 6 | + Arduino IoT Cloud Properties description |
| 7 | +
|
| 8 | + The following variables are automatically generated and updated when changes are made to the Thing properties |
| 9 | +
|
| 10 | + bool Switch; |
| 11 | +
|
| 12 | + Properties which are marked as READ/WRITE in the Cloud Thing will also have functions |
| 13 | + which are called when their values are changed from the Dashboard. |
| 14 | + These functions are generated with the Thing and added at the end of this sketch. |
| 15 | +*/ |
| 16 | + |
| 17 | +#include "thingProperties.h" |
| 18 | + |
| 19 | +void setup() { |
| 20 | + // Initialize serial and wait for port to open: |
| 21 | + Serial.begin(9600); |
| 22 | + // This delay gives the chance to wait for a Serial Monitor without blocking if none is found |
| 23 | + delay(1500); |
| 24 | + |
| 25 | + // Defined in thingProperties.h |
| 26 | + initProperties(); |
| 27 | + |
| 28 | + // Connect to Arduino IoT Cloud |
| 29 | + ArduinoCloud.begin(ArduinoIoTPreferredConnection, "mqtts-sa.iot.oniudra.cc"); |
| 30 | + |
| 31 | + /* |
| 32 | + The following function allows you to obtain more information |
| 33 | + related to the state of network and IoT Cloud connection and errors |
| 34 | + the higher number the more granular information you’ll get. |
| 35 | + The default is 0 (only errors). |
| 36 | + Maximum is 4 |
| 37 | + */ |
| 38 | + setDebugMessageLevel(2); |
| 39 | + ArduinoCloud.printDebugInfo(); |
| 40 | +} |
| 41 | + |
| 42 | +float latMov = 45.5058224, lonMov = 9.1628673; |
| 43 | +float latArd = 45.0502078, lonArd = 7.6674765; |
| 44 | + |
| 45 | +float hueRed = 0.0, satRed = 100.0, briRed = 100.0; |
| 46 | +float hueGreen = 80.0, satGreen = 100.0, briGreen = 100.0; |
| 47 | + |
| 48 | +void loop() { |
| 49 | + ArduinoCloud.update(); |
| 50 | + // Your code here |
| 51 | + |
| 52 | + Switch = !Switch; |
| 53 | + if (Switch) { |
| 54 | + Loc = { .lat = latMov, .lon = lonMov }; |
| 55 | + Color = { .hue = hueRed, .sat = satRed, .bri = briRed }; |
| 56 | + } else { |
| 57 | + Loc = { .lat = latArd, .lon = lonArd }; |
| 58 | + Color = { .hue = hueGreen, .sat = satGreen, .bri = briGreen }; |
| 59 | + } |
| 60 | + delay(5000); |
| 61 | +} |
| 62 | + |
| 63 | + |
| 64 | +void onSwitchChange() { |
| 65 | + // Do something |
| 66 | + digitalWrite(LED_BUILTIN, Switch); |
| 67 | +} |
| 68 | + |
| 69 | +void onColorChange() { |
| 70 | + // Do something |
| 71 | + Serial.print("Hue = "); |
| 72 | + Serial.println(Color.getValue().hue); |
| 73 | + Serial.print("Sat = "); |
| 74 | + Serial.println(Color.getValue().sat); |
| 75 | + Serial.print("Bri = "); |
| 76 | + Serial.println(Color.getValue().bri); |
| 77 | +} |
0 commit comments