#include <ThingSpeak.h>
#include "WiFi.h"
WiFiClient client;
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
#define LED_Pin 12
unsigned long Channel_ID=1789214;
const char* API_Key = "IIGXONMO7G7MUDFW";
const int Field_num = 3;
void setup()
{
Serial.begin(9600);
WiFi.disconnect();
WiFi.begin(ssid,pass);
while ((!(WiFi.status() == WL_CONNECTED))) {
delay(300);
Serial.print(".");
}
Serial.println("");
Serial.println("WiFi connected");
Serial.println("IP address: ");
Serial.println(WiFi.localIP());
pinMode(LED_Pin, OUTPUT);
ThingSpeak.begin(client);
}
void loop()
{
int A = ThingSpeak.readLongField(Channel_ID, Field_num, API_Key);
Serial.println(A);
digitalWrite(LED_Pin, A);
// ON https://api.thingspeak.com/update?key=FISFX37SVC5OR3L5&field3=1
// OFF https://api.thingspeak.com/update?key=FISFX37SVC5OR3L5&field3=0
}