park heumyong
/
Nucleo_SC_SR04
sc04
Embed:
(wiki syntax)
Show/hide line numbers
main.cpp
00001 #include "mbed.h" 00002 #include "HCSR04.h" 00003 Serial pc(USBTX, USBRX); // USART2 : PA2,PA3 00004 HCSR04 u_sen(PC_7, PA_9); // 초음파 센서 00005 int main() 00006 { float dist = 0; 00007 while(1) 00008 { u_sen.startMeas(); //거리 측정 00009 wait(0.1); 00010 u_sen.getMeas(dist); //m단위 변환 00011 pc.printf("DIST %0.2fm \r\n",dist); //출력 00012 wait(0.2); // delay 200 ms 00013 } 00014 }
Generated on Sat Jul 16 2022 01:04:03 by 1.7.2