Atsumi Toda
/
altitude_TP
S-240 高度計のプログラム
Diff: main.cpp
- Revision:
- 0:733ff8649dbe
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Tue Nov 14 10:54:34 2017 +0000 @@ -0,0 +1,24 @@ +#include "mbed.h" +/*For the 10 meter sensors (MB1260, MB1261, MB1360, MB1361), + this pin outputs analog voltage with a scaling factor of (Vcc/1024) per 2 cm. + A supply of 5V yields ~4.9mV/2cm., and 3.3V yields ~3.2mV/2cm. + The output is buffered and corresponds to the most recent range data*/ + +DigitalOut myled(LED1); + +AnalogIn vin(p15); + +double ain=0; + +int main() { + while(1) { + myled=1; + ain=vin.read()*3.3; + printf("ain=%.4fV,altitude=%.1fm\r\n",ain,ain*1000/1.6/100); + /* printf("ain=%.4fV,altitude=%.1fm\r\n",ain,ain*1000/2.45/100);*/ + + wait(0.5); + + + } +}