Program that execute AEB system

Dependencies:   AEB Ultrasonic Controller_Master mbed

Dependents:   AEB

Revision:
0:64a08651b7c0
Child:
1:8cb509a319e5
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Thu Jun 02 21:23:36 2016 +0000
@@ -0,0 +1,42 @@
+/*
+* An example showing how to use the Ultrasonic library
+*/
+#include "mbed.h"
+#include "Ultrasonic.h"
+#include "Controller_Master.h"
+#include "rtwtypes.h"
+
+DigitalOut led_R(LED_RED);
+DigitalOut led_B(LED_BLUE);
+DigitalIn  slave(D6);
+Ticker t;
+float V = 50;
+
+Serial  pc(USBTX, USBRX); // tx, rx
+
+void step();
+
+int main()
+{
+    
+    Ultrasonic_init();  // Just call this funtion to initialize the ultrasonic sensor
+    Controller_Master_U.V = V;
+    Controller_Master_U.D_M = read_cm();
+    Controller_Master_U.Slave = slave.read();
+    Controller_Master_initialize();
+    t.attach(&step,0.2);
+    while (true) {
+        wait(0.2);
+    }
+}
+
+
+void step()
+{
+    Controller_Master_U.D_M = read_cm();
+    Controller_Master_U.Slave = slave.read();
+    pc.printf("Distance: %f \n", Controller_Master_U.D_M);    // Call read_cm() to get the distance in cm
+    Controller_Master_step();
+    led_B = Controller_Master_Y.LED_BLUE;
+    led_R = Controller_Master_Y.LED_RED;
+}
\ No newline at end of file