#include <NewPing.h>
#define BLYNK_TEMPLATE_ID "TMPL6hFw_J1jX"
#define BLYNK_TEMPLATE_NAME "test"
#define BLYNK_AUTH_TOKEN "iVeX4RxYBfW4DkJNZ7-nHIs9V6W2I0q5"
NewPing sonar(4, 0,1000);
#include <WiFi.h>
#include <WiFiClient.h>
#include <BlynkSimpleEsp32.h>
char ssid[] = "Wokwi-GUEST";
char pass[] = "";
BlynkTimer timer;
int a =0;
void timerk(){
int a=sonar.ping();
Blynk.virtualWrite(V0,a/ US_ROUNDTRIP_CM);
}
void setup() {
Serial.begin(9600);
// put your setup code here, to run once:
Blynk.begin(BLYNK_AUTH_TOKEN, ssid, pass);
timer.setInterval(1000L,timerk);
}
void loop() {
gerak();
// this speeds up the simulation
Blynk.run(); timer.run();
}
void gerak(){
int a = sonar.ping();
if (a>=100){
int b= 1;
Serial.println(b);
}
Serial.println(a/ US_ROUNDTRIP_CM);
}