int t1 = 19;
int e1 = 16;
int led = 25;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
pinMode(t1, OUTPUT);
pinMode(e1, INPUT);
pinMode(led, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(t1, HIGH);
delay(500);
digitalWrite(t1, LOW);
int input = pulseIn(e1,HIGH);
int output = input*0.034/2;
Serial.println(output);
if(output > 150)
{
digitalWrite(led, HIGH);
}
else { digitalWrite(led, LOW); }
delay(10); // this speeds up the simulation
}