#include<WiFi.h>
#include<WiFiClient.h>
#include<ThingSpeak.h>
#define LDR_pin 32
const char* WIFI_NAME ="Wokwi-Guest";
const char* WIFI_PASSWORD = "";
const int myChannelNumber = 3051398;
const char* myApiKey = "6S3490Y1FDTTN800";
const char* server = "api.thingspeak.com";
WiFiClient client;
void setup() {
// put your setup code here, to run once:
pinMode(LDR_pin, INPUT);
WiFi.begin(WIFI_NAME, WIFI_PASSWORD);
ThingSpeak.begin(client);
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
int ldr = analogRead(LDR_pin);
int mappedValue = map(ldr,0,4096, 100,0);
Serial.println(mappedValue);
ThingSpeak.setField(1, mappedValue);
ThingSpeak.writeFields(myChannelNumber,myApiKey);
delay(1000); // this speeds up the simulation
}