/**
* @file main.cpp
* @brief main source of project
*/
#include <Arduino.h>
#include "HC_SR04.h"
// تعریف پینها
#define TRIG_PIN 3 // پایه تحریک سنسور
#define ECHO_PIN 2 // پایه بازتاب سنسور
// declare variables
// تعریف شی مدیریت فاصله سنج
HC_SR04 distance_handler(TRIG_PIN, ECHO_PIN, 100);
void setup() {
// put your setup code here, to run once:
// راه اندازی شی مدیریت فاصله سنج
distance_handler.begin();
// شروع ارتباط سریال
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
Serial.println(distance_handler.read_smoothed_distance());
delay(500);
Serial.println(distance_handler.is_object_detected(30));
delay(500);
}