Program that execute AEB system
Dependencies: AEB Ultrasonic Controller_Master mbed
main.cpp
- Committer:
- AndreaAndreoli
- Date:
- 2016-06-02
- Revision:
- 0:64a08651b7c0
- Child:
- 1:8cb509a319e5
File content as of revision 0:64a08651b7c0:
/* * 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; }