초음파거리센서2 아두이노 초음파거리센서 코드( 연동 ) #define TRIG_PIN 6 #define ECHO_PIN 7 unsigned long duration, distance; int send_time = 500; unsigned long befor_time = 0; String last_data = "S"; void setup() { pinMode(ECHO_PIN, INPUT); pinMode(TRIG_PIN, OUTPUT); Serial.begin(115200); befor_time = millis(); } void loop() { unsigned long now = millis(); if( now - befor_time >= send_time ){ befor_time = now; digitalWrite(TRIG_PIN, HIGH); delayMi.. 2022. 11. 30. 아두이노 초음파거리센서 코드 #define TRIG_PIN 6 #define ECHO_PIN 7 unsigned long duration, distance; int send_time = 500; unsigned long befor_time = 0; void setup() { pinMode(ECHO_PIN, INPUT); pinMode(TRIG_PIN, OUTPUT); Serial.begin(115200); befor_time = millis(); } void loop() { unsigned long now = millis(); if( now - befor_time >= send_time ){ befor_time = now; digitalWrite(TRIG_PIN, HIGH); delayMicroseconds(10); digitalW.. 2022. 11. 29. 이전 1 다음