#define TRIG 7
#define ECHO 6
long duration;
int distance;
void setup() {
// put your setup code here, to run once:
pinMode(TRIG, OUTPUT);
pinMode(ECHO, INPUT);
Serial.begin(9600);//khởi tạo giao tiếp serial với tốc độ truyền dữ liệu là 9600
}
void loop() {
// put your main code here, to run repeatedly:
// đặt chân TRIG ở mức thấp là 2000 micro giây
digitalWrite(TRIG,LOW);
delayMicroseconds(2);
digitalWrite(TRIG , HIGH);
delayMicroseconds(10);
}