Ultrasoon test

Dependencies:   mbed

Committer:
TVA
Date:
Mon Feb 05 12:51:39 2018 +0000
Revision:
4:a4364bae0a05
Parent:
1:0490a15c76e4
Ultrasoon test

Who changed what in which revision?

UserRevisionLine numberNew contents of line
bcostm 0:c2d1ad5059da 1 #include "mbed.h"
bcostm 0:c2d1ad5059da 2
bcostm 0:c2d1ad5059da 3 AnalogIn analog_value(A0);
bcostm 0:c2d1ad5059da 4
bcostm 1:0490a15c76e4 5 DigitalOut led(LED1);
bcostm 1:0490a15c76e4 6
bcostm 0:c2d1ad5059da 7 int main() {
TVA 4:a4364bae0a05 8 float meas, distance;
bcostm 1:0490a15c76e4 9
TVA 4:a4364bae0a05 10 printf("\nAnalogIn example\n\r");
bcostm 1:0490a15c76e4 11
bcostm 1:0490a15c76e4 12 while(1) {
bcostm 1:0490a15c76e4 13 meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
bcostm 1:0490a15c76e4 14 meas = meas * 3300; // Change the value to be in the 0 to 3300 range
TVA 4:a4364bae0a05 15 distance = meas/3.2;
TVA 4:a4364bae0a05 16 printf("measure = %.0f mV %0.f cm\n\r", meas, distance);
bcostm 0:c2d1ad5059da 17 wait(0.2); // 200 ms
bcostm 0:c2d1ad5059da 18 }
bcostm 0:c2d1ad5059da 19 }