ArduinoLibraries/libraries/HC-SR04/examples/SR04_Example/SR04_Example.ino

18 lines
261 B
Arduino
Raw Permalink Normal View History

2022-02-20 21:15:04 +00:00
#include "SR04.h"
#define TRIG_PIN 12
#define ECHO_PIN 11
SR04 sr04 = SR04(ECHO_PIN,TRIG_PIN);
long a;
void setup() {
Serial.begin(9600);
delay(1000);
}
void loop() {
a=sr04.Distance();
Serial.print(a);
Serial.println("cm");
delay(1000);
}