Nuvoton
/
NuMaker-mbed-ADC0_MQ3
NuMaker ADC read gas sensor (MQ3)
Revision 12:015640054db1, committed 2021-02-24
- Comitter:
- SHLIU1@OANBE02333.nuvoton.com
- Date:
- Wed Feb 24 16:27:23 2021 +0800
- Parent:
- 11:58b88abed368
- Commit message:
- Support the both V5.X and V6.X
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 58b88abed368 -r 015640054db1 main.cpp --- a/main.cpp Thu Apr 19 09:31:55 2018 +0800 +++ b/main.cpp Wed Feb 24 16:27:23 2021 +0800 @@ -8,11 +8,19 @@ int main(void) { +#ifdef MBED_MAJOR_VERSION + printf("Mbed OS version %d.%d.%d\r\n\n", MBED_MAJOR_VERSION, MBED_MINOR_VERSION, MBED_PATCH_VERSION); +#endif 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; +#if MBED_MAJOR_VERSION >= 6 + ThisThread::sleep_for(200); +#else wait(0.2f); +#endif + } }