Created libraries2
Dependencies: mbed ultrasonic
Diff: main.cpp
- Revision:
- 8:454f1f82aca4
- Parent:
- 6:0d4008544238
- Child:
- 9:74d372e08f41
diff -r 0d4008544238 -r 454f1f82aca4 main.cpp --- a/main.cpp Thu Apr 16 13:55:42 2015 +0000 +++ b/main.cpp Fri Apr 17 15:33:33 2015 +0000 @@ -5,6 +5,8 @@ DigitalOut TX2(D8); // Use pin D8 DigitalOut HVoff(D6); // Use pin D6 InterruptIn signal(D7); // Use pin D7 +DigitalOut tresh (D5); +DigitalOut high (D4); Timeout to1; Timer t1; Serial pc(SERIAL_TX, SERIAL_RX); @@ -14,20 +16,23 @@ void TX1_send(){ previous = 1; - HVoff = 0; + HVoff = 1; + //tresh = 0; 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 + TX1 = 1; t1.reset(); - HVoff = 1; + HVoff = 0; + //wait(0.0001); + //tresh = 1; to1.attach(TX1_send,0.1); // Sends for 1000us } void signal_reciev(){ float _time = t1.read(); - if (_time<0.006 && _time>0.0007){ + if (_time<0.006){ if (t1.read()>previous){ pc.printf("check"); @@ -50,7 +55,8 @@ t1.start(); signal.fall(&signal_reciev); - TX2 = 1; + TX2 = 0; + //high = 1; TX1_send(); while(1); } \ No newline at end of file