1
- #include " arduino_secrets.h"
2
1
/*
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 switchButton;
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.
2
+ This sketch demonstrates how to use more complex cloud data types such as a colour or coordinates.
15
3
16
4
This sketch is compatible with:
17
- - MKR 1000
18
- - MKR WIFI 1010
5
+ - MKR 1000
6
+ - MKR WIFI 1010
7
+ - MKR GSM 1400
8
+ - MKR NB 1500
9
+ - MKR WAN 1300/1310
10
+ - ESP 8266
19
11
*/
20
12
13
+ #include " arduino_secrets.h"
21
14
#include " thingProperties.h"
22
15
23
16
void setup () {
24
- // Initialize serial and wait for port to open:
17
+ /* Initialize serial and wait up to 5 seconds for port to open */
25
18
Serial.begin (9600 );
26
- // This delay gives the chance to wait for a Serial Monitor without blocking if none is found
27
- delay (1500 );
19
+ for (unsigned long const serialBeginTime = millis (); !Serial && (millis () - serialBeginTime > 5000 ); ) { }
28
20
29
- // Defined in thingProperties.h
21
+ /* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
30
22
initProperties ();
31
23
32
- // Connect to Arduino IoT Cloud
24
+ /* Initialize Arduino IoT Cloud library */
33
25
ArduinoCloud.begin (ArduinoIoTPreferredConnection);
34
26
35
- /*
36
- The following function allows you to obtain more information
37
- related to the state of network and IoT Cloud connection and errors
38
- the higher number the more granular information you’ll get.
39
- The default is 0 (only errors).
40
- Maximum is 4
41
- */
42
- setDebugMessageLevel (2 );
27
+ setDebugMessageLevel (DBG_INFO);
43
28
ArduinoCloud.printDebugInfo ();
44
29
}
45
30
@@ -51,27 +36,22 @@ float hueGreen = 80.0, satGreen = 100.0, briGreen = 100.0;
51
36
52
37
void loop () {
53
38
ArduinoCloud.update ();
54
- // Your code here
55
-
56
- switchButton = !switchButton;
57
- if (switchButton) {
58
- location = Location (latMov, lonMov);
59
- color = Color (hueRed, satRed, briRed);
60
- } else {
61
- location = Location (latArd, lonArd);
62
- color = Color (hueGreen, satGreen, briGreen);
63
- }
64
- delay (5000 );
65
39
}
66
40
67
-
68
41
void onSwitchButtonChange () {
69
- // Do something
70
- digitalWrite (LED_BUILTIN, switchButton);
42
+ if (switchButton)
43
+ {
44
+ location = Location (latMov, lonMov);
45
+ color = Color (hueRed, satRed, briRed);
46
+ }
47
+ else
48
+ {
49
+ location = Location (latArd, lonArd);
50
+ color = Color (hueGreen, satGreen, briGreen);
51
+ }
71
52
}
72
53
73
54
void onColorChange () {
74
- // Do something
75
55
Serial.print (" Hue = " );
76
56
Serial.println (color.getValue ().hue );
77
57
Serial.print (" Sat = " );
0 commit comments