Atsumi Toda
/
altitude_TP
S-240 高度計のプログラム
Revision 0:733ff8649dbe, committed 2017-11-14
- Comitter:
- Joeatsumi
- Date:
- Tue Nov 14 10:54:34 2017 +0000
- Commit message:
- ?????????
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
mbed.bld | Show annotated file Show diff for this revision Revisions of this file |
--- /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); + + + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Tue Nov 14 10:54:34 2017 +0000 @@ -0,0 +1,1 @@ +https://mbed.org/users/mbed_official/code/mbed/builds/675da3299148 \ No newline at end of file