sc04

Dependencies:   mbed HCSR04

Committer:
hypark
Date:
Wed May 30 02:35:43 2018 +0000
Revision:
1:b424b6de3632
Parent:
0:f03a985dcde2
1

Who changed what in which revision?

UserRevisionLine numberNew contents of line
hypark 0:f03a985dcde2 1 #include "mbed.h"
hypark 0:f03a985dcde2 2 #include "HCSR04.h"
hypark 0:f03a985dcde2 3 Serial pc(USBTX, USBRX); // USART2 : PA2,PA3
hypark 0:f03a985dcde2 4 HCSR04 u_sen(PC_7, PA_9); // 초음파 센서
hypark 0:f03a985dcde2 5 int main()
hypark 0:f03a985dcde2 6 { float dist = 0;
hypark 0:f03a985dcde2 7 while(1)
hypark 0:f03a985dcde2 8 { u_sen.startMeas(); //거리 측정
hypark 0:f03a985dcde2 9 wait(0.1);
hypark 0:f03a985dcde2 10 u_sen.getMeas(dist); //m단위 변환
hypark 1:b424b6de3632 11 pc.printf("DIST %0.2fm \r\n",dist); //출력
hypark 0:f03a985dcde2 12 wait(0.2); // delay 200 ms
hypark 0:f03a985dcde2 13 }
hypark 0:f03a985dcde2 14 }