Skip to content

Instantly share code, notes, and snippets.

@alexastrum
Last active July 29, 2020 22:12
Show Gist options
  • Save alexastrum/507d377a5c3deb128868be2c1ccf832c to your computer and use it in GitHub Desktop.
Save alexastrum/507d377a5c3deb128868be2c1ccf832c to your computer and use it in GitHub Desktop.
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.");
}
}
// 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