Please explain this Arduino code #include #include #include #include #include /* Set these to your desired credentials. */ const char *ssid = "admin";  //ENTER YOUR WIFI SETTINGS const char *password = "admin"; //Web/Server address to read/write from const char *host = "raw.githubusercontent.com"; const int httpsPort = 443;  //HTTPS= 443 and HTTP = 80 //SHA1 finger print of certificate use web browser to view and copy const char fingerprint[] PROGMEM = " "; void setup() {   pinMode(2, OUTPUT);   pinMode(0, OUTPUT);   pinMode(4, OUTPUT);   pinMode(5, OUTPUT);   delay(1000);   Serial.begin(115200);   WiFi.mode(WIFI_OFF);        //Prevents reconnection issue (taking too long to connect)   delay(1000);   WiFi.mode(WIFI_STA);        //Only Station No AP, This line hides the viewing of ESP as wifi hotspot   WiFi.begin(ssid, password);     //Connect to your WiFi router   Serial.println("");   Serial.print("Connecting");   // Wait for connection   while (WiFi.status() != WL_CONNECTED) {     delay(0);     Serial.print(".");   } }   void loop() {   WiFiClientSecure httpsClient;    //Declare object of class WiFiClient   Serial.println(host);   Serial.printf("Using fingerprint '%s'\n", fingerprint);   httpsClient.setFingerprint(fingerprint);   httpsClient.setTimeout(15000); // 15 Seconds   delay(1000);   Serial.print("HTTPS Connecting");   int r = 0; //retry counter   while ((!httpsClient.connect(host, httpsPort)) && (r < 30)) {     delay(100);     Serial.print(".");     r++;   }   if (r == 30) {     Serial.println("Connection failed");   }   else {     Serial.println("Connected to web");   }   String ADCData, getData, Link;   //GET Data   Link = "";   Serial.print("requesting URL: ");   Serial.println(host + Link);   httpsClient.print(String("GET ") + Link + " HTTP/1.1\r\n" +                     "Host: " + host + "\r\n" +                     "Connection: close\r\n\r\n");   Serial.println("request sent");   while (httpsClient.connected()) {     String line = httpsClient.readStringUntil('\n');     if (line == "\r") {       Serial.println("headers received");       break;     }   }   Serial.println("reply was:");   Serial.println("==========");   String line;   while (httpsClient.available()) {     line = httpsClient.readStringUntil('\n');  //Read Line by Line     Serial.print(line);     String load = line;     StaticJsonDocument<400> docum;     deserializeJson(docum, load);     JsonArray numbers = docum["numbers"];     for (int y = 0; y < 16; y++) {       int x = numbers[y];       Serial.printf("Currently Showing: %u\n", x);       if (x >= 8) {         x = x - 8;         digitalWrite(5, HIGH);       }       if (x >= 4) {         x = x - 4;         digitalWrite(4, HIGH);       }       if (x >= 2) {         x = x - 2;         digitalWrite(0, HIGH);       }       if (x >= 1) {         x = x - 1;         digitalWrite(2, HIGH);       }       delay(1000);       // reset all LED state       digitalWrite(2, LOW);       digitalWrite(0, LOW);       digitalWrite(4, LOW);       digitalWrite(5, LOW);     }   } Serial.println("====================="); Serial.println("closing connection"); delay(5000);  }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

Please explain this Arduino code

#include <ESP8266WiFi.h>
#include <WiFiClientSecure.h>
#include <ESP8266WebServer.h>
#include <ESP8266HTTPClient.h>
#include <ArduinoJson.h>
/* Set these to your desired credentials. */
const char *ssid = "admin";  //ENTER YOUR WIFI SETTINGS
const char *password = "admin";

//Web/Server address to read/write from
const char *host = "raw.githubusercontent.com";
const int httpsPort = 443;  //HTTPS= 443 and HTTP = 80

//SHA1 finger print of certificate use web browser to view and copy
const char fingerprint[] PROGMEM = " ";

void setup() {
  pinMode(2, OUTPUT);
  pinMode(0, OUTPUT);
  pinMode(4, OUTPUT);
  pinMode(5, OUTPUT);
  delay(1000);
  Serial.begin(115200);
  WiFi.mode(WIFI_OFF);        //Prevents reconnection issue (taking too long to connect)
  delay(1000);
  WiFi.mode(WIFI_STA);        //Only Station No AP, This line hides the viewing of ESP as wifi hotspot

  WiFi.begin(ssid, password);     //Connect to your WiFi router
  Serial.println("");

  Serial.print("Connecting");
  // Wait for connection
  while (WiFi.status() != WL_CONNECTED) {
    delay(0);
    Serial.print(".");
  }
}
  void loop() {
  WiFiClientSecure httpsClient;    //Declare object of class WiFiClient

  Serial.println(host);
  Serial.printf("Using fingerprint '%s'\n", fingerprint);
  httpsClient.setFingerprint(fingerprint);
  httpsClient.setTimeout(15000); // 15 Seconds
  delay(1000);

  Serial.print("HTTPS Connecting");
  int r = 0; //retry counter
  while ((!httpsClient.connect(host, httpsPort)) && (r < 30)) {
    delay(100);
    Serial.print(".");
    r++;
  }
  if (r == 30) {
    Serial.println("Connection failed");
  }
  else {
    Serial.println("Connected to web");
  }

  String ADCData, getData, Link;

  //GET Data
  Link = "";

  Serial.print("requesting URL: ");
  Serial.println(host + Link);

  httpsClient.print(String("GET ") + Link + " HTTP/1.1\r\n" +
                    "Host: " + host + "\r\n" +
                    "Connection: close\r\n\r\n");

  Serial.println("request sent");


  while (httpsClient.connected()) {
    String line = httpsClient.readStringUntil('\n');
    if (line == "\r") {
      Serial.println("headers received");
      break;
    }
  }

  Serial.println("reply was:");
  Serial.println("==========");
  String line;
  while (httpsClient.available()) {
    line = httpsClient.readStringUntil('\n');  //Read Line by Line
    Serial.print(line);
    String load = line;

    StaticJsonDocument<400> docum;
    deserializeJson(docum, load);

    JsonArray numbers = docum["numbers"];

    for (int y = 0; y < 16; y++) {
      int x = numbers[y];
      Serial.printf("Currently Showing: %u\n", x);
      if (x >= 8) {
        x = x - 8;
        digitalWrite(5, HIGH);
      }
      if (x >= 4) {
        x = x - 4;
        digitalWrite(4, HIGH);
      }
      if (x >= 2) {
        x = x - 2;
        digitalWrite(0, HIGH);
      }
      if (x >= 1) {
        x = x - 1;
        digitalWrite(2, HIGH);
      }
      delay(1000);
      // reset all LED state
      digitalWrite(2, LOW);
      digitalWrite(0, LOW);
      digitalWrite(4, LOW);
      digitalWrite(5, LOW);
    }

  }

Serial.println("=====================");
Serial.println("closing connection");

delay(5000); 


}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY