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.
main.cpp
- Committer:
- shliu1
- Date:
- 2016-12-22
- Revision:
- 5:fc7ae837af13
- Parent:
- 1:605a7fdd4e93
- Child:
- 7:e951e13ae71e
File content as of revision 5:fc7ae837af13:
// NuMaker-PFM-NUC472 use ADC0 (A0/PE_1) to read gas sensor (MQ-3) #include "mbed.h" #if defined(TARGET_NUMAKER_PFM_NUC472) AnalogIn adc0(PE_1); // A0 connected to MQ-3 gas sensor #elif defined(TARGET_NUMAKER_PFM_M453) AnalogIn adc0(PB_0); #endif 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); } }