Created libraries2
Dependencies: mbed ultrasonic
Diff: main.cpp
- Revision:
- 10:066af872cf0e
- Parent:
- 7:c763b5d61dee
--- a/main.cpp Thu Apr 16 16:45:58 2015 +0000 +++ b/main.cpp Mon Apr 20 15:30:58 2015 +0000 @@ -16,14 +16,13 @@ void TX1_send(){ previous = 1; - HVoff = 0; + HVoff = 1; TX1.period(0.0000252); // Set the period of TX1 to 25.2us (39,682kHz) TX1.pulsewidth(0.0000116); // Set the pulsewidth of TX1 to 11.6us (ON) - wait(0.0002016); // Waits 201.6us - TX1 = 0; + wait(0.000300); // Waits 201.6us - New 300us + TX1 = 1; t1.reset(); - wait(0.0000116); - HVoff = 1; + HVoff = 0; to1.attach(TX1_send,0.1); // Sends for 1000us } @@ -32,7 +31,7 @@ float _time = t1.read(); - if (_time<0.006 && _time>0.0008){ + if (_time<0.006 && _time>0.000036){ if (t1.read()>previous){ } @@ -52,7 +51,6 @@ while(US_count<20){pc.printf("\r");} - float sum = 0; for(int i=0;i<20;i++){ @@ -64,8 +62,8 @@ return sum/20; } int main() { - t1.start(); + t1.start(); float nks = get_avg(); - pc.printf("Avg = %f\r\n",nks); + pc.printf("Avg = %f\r\n",nks); } \ No newline at end of file