Last active
July 29, 2020 22:12
-
-
Save alexastrum/507d377a5c3deb128868be2c1ccf832c to your computer and use it in GitHub Desktop.
Firebase IoT https://medium.com/@alexastrum/connect-arduino-nano-33-iot-to-firebase-rtdb-in-5-minutes-347ec6917da5 #1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void displayText(String msg) { Serial.println(msg); } | |
void blinkLED(int duration) { | |
digitalWrite(LED_BUILTIN, HIGH); | |
delay(duration); | |
digitalWrite(LED_BUILTIN, LOW); | |
delay(100); | |
} | |
void displayStatus(String msg) { | |
displayText(msg); | |
blinkLED(100); | |
} | |
void displayError(String msg) { | |
displayText("Error: " + msg); | |
blinkLED(300); | |
} | |
void displaySuspend(String msg) { | |
displayText("Execution suspended: " + msg); | |
digitalWrite(LED_BUILTIN, HIGH); // Turn on LED. | |
while (true) { | |
// Stop execution. | |
} | |
} | |
void setupDisplay() { | |
pinMode(LED_BUILTIN, OUTPUT); | |
Serial.begin(115200); | |
if (!Serial) { | |
// Allow enough time for our Serial Monitor to connect to the serial port. | |
delay(3000); | |
} | |
if (Serial) { | |
Serial.println("\nSerial port connected."); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Make sure we've installed all needed libraries. | |
#include <WiFiNINA.h> | |
#include <ArduinoECCX08.h> | |
#include <ArduinoHttpClient.h> | |
#include <ArduinoJson.h> | |
#include "display.h" | |
void setup() | |
{ | |
setupDisplay(); | |
} | |
void loop() | |
{ | |
displayStatus("Hello world!"); | |
delay(1000); // Wait for a second. | |
displaySuspend("All done!"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment