Ultrasoon test

Dependencies:   mbed

main.cpp

Committer:
TVA
Date:
2018-02-05
Revision:
4:a4364bae0a05
Parent:
1:0490a15c76e4

File content as of revision 4:a4364bae0a05:

#include "mbed.h"
 
AnalogIn analog_value(A0);
 
DigitalOut led(LED1);

int main() {
    float meas, distance;
    
    printf("\nAnalogIn example\n\r");
    
    while(1) {
        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
        meas = meas * 3300; // Change the value to be in the 0 to 3300 range
        distance = meas/3.2;
        printf("measure = %.0f mV %0.f cm\n\r", meas, distance);
        wait(0.2); // 200 ms
    }
}