Created libraries2

Dependencies:   mbed ultrasonic

Revision:
4:ae7f8a25c748
Parent:
3:b6f543e4508a
Child:
5:b2df25183cb1
--- a/main.cpp	Tue Mar 10 15:24:01 2015 +0000
+++ b/main.cpp	Thu Apr 16 08:54:29 2015 +0000
@@ -1,31 +1,45 @@
 #include "mbed.h"
 #include "ultrasonic.h"
 
-PwmOut TX(D9);
-InterruptIn irq(D8);
+PwmOut TX1(D9);                             // Use pin D9
+DigitalOut TX2(D8);                         // Use pin D8
+DigitalOut HVoff(D6);                       // Use pin D6
+InterruptIn signal(D7);                     // Use pin D7
+//DigitalOut tresh(D7);
+Timeout to1;
 Timer t1;
-Timeout to;
 Serial pc(SERIAL_TX, SERIAL_RX);
 
-void TX_send(){
-     t1.reset();
-     TX.write(0.5);
-     wait_us(125);
-     TX = 0;
-     to.attach(TX_send,1);
+void TX1_send(){
+    HVoff = 0;
+    //tresh = 1;
+    t1.reset();
+    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;
+    //tresh =0;
+    HVoff = 1;
+    //pc.printf("It writes TX1\r\n");
+    to1.attach(TX1_send,0.01);              // Sends for 1000us
+    wait_ms(86);                            // Waits 86ms. Total 100ms
     }
 
-void get_dist(){
-    int dist = t1.read_us();
-    pc.printf("time = %d", dist);
+
+void signal_reciev(){
+    
+    pc.printf("test1");
+    
+    float time = t1.read();
+    
+    pc.printf("%f/r/n", time);
+    
     }
-    
+
 int main() {
-    t1.start();
-    TX.period_us(25);
-    TX_send();
-    while(1){
-        irq.rise(&get_dist);
-        }
-    
-}
+    TX2 = 1;
+    TX1_send();
+    signal.rise(&signal_reciev);
+    //pc.printf("%f\r\n", volt.read());       // Function to write to serial chart 
+    while(1);
+    }
\ No newline at end of file