#include<ThingSpeak.h>
#include<WiFi.h>
#define Led1 12
const char * SSID = "Wokwi-GUEST";
const char * PASS = "";
WiFiClient client
unsigned long ChannelNumber = 2743913;
const * char ReadApiKey = "G6CGYCXTKIV7U3N6";
const * int FieldNumber = 1;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
Serial.println("Hello, ESP32!");
pinMode(Led1, OUTPUT);
WiFi.begin(SSID, PASS);
Serial.print("Menghubungkan");
while (WiFi.status() != WL_CONNECTED){
delay(500);
Serial.print(".");
}
Serial.println();
Serial.print("Terhubung, Alamat IP : ");
Serial.println(WiFi.LocalIP());
ThingSpeak.begin(client);
}
void loop() {
// put your main code here, to run repeatedly:
int A = ThingSpeak.readLongField(ChannelNumber, FieldNumber, ReadApiKey);
if(A == 1){
Serial.println("Lampu Menyala");
digitalWrite(Led1, HIGH);
}
delay(10); // this speeds up the simulation
}