Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 55 additions & 0 deletions examples/ArduinoIoTCloud_LED_switch/ArduinoIoTCloud_LED_switch.ino
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
/*
This sketch demonstrates how to exchange data between your board and the Arduino IoT Cloud.

Connect a potentiometer (or other analog sensor) to A1 and an LED to Digital Pin 5.
When the potentiometer (or sensor) value changes the data is sent to the Cloud.
When you flip the switch in the Cloud dashboard the onboard LED lights gets turned ON or OFF.


*/
#include "arduino_secrets.h"
#include "thingProperties.h"

void setup() {

// Initialize serial and wait for port to open:
Serial.begin(9600);
// wait up to 5 seconds for user to open Serial port
unsigned long serialBeginTime = millis();
while (!Serial && (millis() - serialBeginTime > 5000));

Serial.println("Starting Arduino IoT Cloud Example");

// initProperties takes care of connecting your sketch variables to the ArduinoIoTCloud object
initProperties();
// tell ArduinoIoTCloud to use our WiFi connection
ArduinoCloud.begin(ArduinoIoTPreferredConnection);

/*
The following function allows you to obtain more information
related to the state of network and IoT Cloud connection and errors
the higher number the more granular information you'll get.
The default is 0 (only errors).
Maximum is 3

setDebugMessageLevel(3);
*/

}

void loop() {
ArduinoCloud.update();

int potentiometer = analogRead(A1);

}


/*
this function is called when the "led" property of your Thing changes
*/
void onLedChange() {
Serial.print("LED set to ");
Serial.println(led);
digitalWrite(LED_BUILTIN, ledSwitch);
}
3 changes: 3 additions & 0 deletions examples/ArduinoIoTCloud_LED_switch/arduino_secrets.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#define SECRET_SSID "YOUR_WIFI_NETWORK_NAME"
#define SECRET_PASS "YOUR_WIFI_PASSWORD"

21 changes: 21 additions & 0 deletions examples/ArduinoIoTCloud_LED_switch/thingProperties.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#include <ArduinoIoTCloud.h>
#include <WiFiConnectionManager.h>


char ssid[] = SECRET_SSID; // your network SSID (name)
char pass[] = SECRET_PASS; // your network password (use for WPA, or use as key for WEP)
// Your THING_ID
#define THING_ID "ARDUINO_IOT_CLOUD_THING_ID"

void onLedChange();

bool led;
int potentiometer;

void initProperties() {
ArduinoCloud.setThingId(THING_ID);
ArduinoCloud.addProperty(led, READWRITE, ON_CHANGE, onLedChange);
ArduinoCloud.addProperty(potentiometer, READ, ON_CHANGE);
}

ConnectionManager *ArduinoIoTPreferredConnection = new WiFiConnectionManager(SECRET_SSID, SECRET_PASS);
149 changes: 0 additions & 149 deletions examples/MKR1000_Cloud_Blink/MKR1000_Cloud_Blink.ino

This file was deleted.

3 changes: 0 additions & 3 deletions examples/MKR1000_Cloud_Blink/arduino_secrets.h

This file was deleted.

Loading