Atsumi Toda
/
altitude_TP
S-240 高度計のプログラム
main.cpp
- Committer:
- Joeatsumi
- Date:
- 2017-11-14
- Revision:
- 0:733ff8649dbe
File content as of revision 0:733ff8649dbe:
#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); } }