#include <NewPing.h>
#define TRIGGER_PIN 4
#define ECHO_PIN 3
#define MAX_DISTANCE 200
#define PING_INTERVAL 330
NewPing sonar(TRIGGER_PIN, ECHO_PIN, MAX_DISTANCE);
void setup() {
Serial.begin(9600);
}
void loop() {
delay(10);
double sonarCm = sonar.ping_cm();
// Serial.print(“Ping: “);
//Serial.print(uS / US_ROUNDTRIP_CM);
//Serial.print(sonarCm);
//Serial.print(“cm”);
if(sonarCm<10 and sonarCm>0)
{
Serial.println(“alerta”);
}
Serial.println(“”);
}