Collision Master for k64f

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
varza
Date:
Wed Dec 12 22:02:04 2018 +0000
Commit message:
master collision;

Changed in this revision

Master_Main_Collision.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 44a0988d76f6 Master_Main_Collision.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/Master_Main_Collision.cpp	Wed Dec 12 22:02:04 2018 +0000
@@ -0,0 +1,65 @@
+#include "mbed.h"
+Timeout response;
+
+DigitalOut green(LED_GREEN);
+DigitalOut red(LED_RED);
+DigitalOut led(D6); 
+DigitalIn  sw2(SW2);
+Serial pc(USBTX, USBRX );
+Serial blue(PTC15, PTC14); //tx, rx
+
+int main()
+{
+    int flag = 0; 
+    char hold = 'b';
+    char recieved; 
+    char send = 'Z';
+    pc.baud(9600);
+    blue.baud(9600);
+    printf("Master connecting to the slave\n");
+
+    while (true) {
+
+        blue.putc(send);
+        wait(0.5f); // wait a small period of time       
+
+        if(blue.readable())//Determine if there is a character available to read.
+        {
+               
+               //--------------------------Temperature Module-----------------------------
+               
+
+                recieved = blue.getc();
+               // printf("\n word = %c \n\r", recieved);
+                int RANGE = ((recieved) - '0');
+                float RANGEFIXED = RANGE; 
+
+                
+                //--------------------------Temperature Module End----------------------------
+                
+                
+                pc.printf("\n Distance from collision = %f Units  \n\r", RANGEFIXED);  
+                if(RANGEFIXED < 50)
+                {
+                     pc.printf("\n Auto Brakes: On - LED --> Blue \n\r");  
+                     flag = 1; 
+             
+                }    
+                else   
+                {
+                    pc.printf("\n Auto Brakes: OFF \n\r"); 
+                    flag = 0; 
+                }
+                    
+        }
+        
+        if(flag == 1)
+            for(int timer = 0; timer < 10; timer++)
+            {
+                wait(0.05f); 
+                led = !led;
+            }
+                
+    }
+
+}
\ No newline at end of file
diff -r 000000000000 -r 44a0988d76f6 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Wed Dec 12 22:02:04 2018 +0000
@@ -0,0 +1,1 @@
+https://os.mbed.com/users/mbed_official/code/mbed/builds/3a7713b1edbc
\ No newline at end of file