1- #include " arduino_secrets.h"
21/*
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.
153
164 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
1911*/
2012
13+ #include " arduino_secrets.h"
2114#include " thingProperties.h"
2215
2316void setup () {
24- // Initialize serial and wait for port to open:
17+ /* Initialize serial and wait up to 5 seconds for port to open */
2518 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 ); ) { }
2820
29- // Defined in thingProperties.h
21+ /* This function takes care of connecting your sketch variables to the ArduinoIoTCloud object */
3022 initProperties ();
3123
32- // Connect to Arduino IoT Cloud
24+ /* Initialize Arduino IoT Cloud library */
3325 ArduinoCloud.begin (ArduinoIoTPreferredConnection);
3426
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);
4328 ArduinoCloud.printDebugInfo ();
4429}
4530
@@ -51,27 +36,22 @@ float hueGreen = 80.0, satGreen = 100.0, briGreen = 100.0;
5136
5237void loop () {
5338 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 );
6539}
6640
67-
6841void 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+ }
7152}
7253
7354void onColorChange () {
74- // Do something
7555 Serial.print (" Hue = " );
7656 Serial.println (color.getValue ().hue );
7757 Serial.print (" Sat = " );
0 commit comments