トランジスタ技術2015年6月号mbedラジコン・カーp179 リスト2 障害物検知器のmbedメイン・プログラム
Dependencies: mbed
Revision 0:bb79ff3ee321, committed 2015-06-01
- Comitter:
- YoshihitoShimada
- Date:
- Mon Jun 01 02:46:57 2015 +0000
- Commit message:
- sonar test program
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 |
diff -r 000000000000 -r bb79ff3ee321 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Mon Jun 01 02:46:57 2015 +0000 @@ -0,0 +1,23 @@ +#include "mbed.h" + +PwmOut S40kHz(P0_21); + +AnalogIn Ain(P0_13); + +DigitalOut StopSignal(P0_20); + +int main() { + + float threshold=0.2; + + S40kHz.period_us(25); // 40kHz + S40kHz.pulsewidth_us(12.5); + + while (1) { + if(Ain > threshold) { + StopSignal=0; // Red LED ON + } else { + StopSignal=1; // Red LED OFF + } + } +} \ No newline at end of file
diff -r 000000000000 -r bb79ff3ee321 mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Mon Jun 01 02:46:57 2015 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/4fc01daae5a5 \ No newline at end of file