Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Revision 0:2e74e9d97542, committed 2016-10-20
- Comitter:
- rkuo2000
- Date:
- Thu Oct 20 12:31:28 2016 +0000
- Commit message:
- mbed ADC read sensor
Changed in this revision
diff -r 000000000000 -r 2e74e9d97542 .gitignore --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/.gitignore Thu Oct 20 12:31:28 2016 +0000 @@ -0,0 +1,4 @@ +.build +.mbed +projectfiles +*.py*
diff -r 000000000000 -r 2e74e9d97542 main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Thu Oct 20 12:31:28 2016 +0000 @@ -0,0 +1,16 @@ +// using NuMaker-PFM-NUC472 ADC0 (A0/PE_1) to read gas sensor (MQ-3) +#include "mbed.h" + +AnalogIn adc0(PE_1); // A0 connected to MQ-3 gas sensor +DigitalOut led(LED1); + +int main(void) +{ + printf("ADC0 start reading...\n\r"); + while (1) { + printf("ADC0 value= 0x%4x, percentage= %3.3f%%\n\r",adc0.read_u16(), adc0.read()*100.0f); + if(adc0 > 0.7f) led = 0; // > 0.7 * Vcc wil turn on led + else led = 1; + wait(0.2f); + } +}
diff -r 000000000000 -r 2e74e9d97542 mbed-os.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed-os.lib Thu Oct 20 12:31:28 2016 +0000 @@ -0,0 +1,1 @@ +https://github.com/ARMmbed/mbed-os/#a6f3fd1a60d5df59246d7caf3f108c4d34e1808e