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.
Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by
Diff: main.cpp
- Revision:
- 8:bc6291805741
- Parent:
- 7:6b50af097b44
- Child:
- 9:21193ec77fbf
--- a/main.cpp Wed Jan 06 07:27:52 2016 +0000 +++ b/main.cpp Wed Feb 03 07:27:16 2016 +0000 @@ -2,9 +2,10 @@ #include "mbed.h" -// Initialize a pins to perform analog input and digital output fucntions -AnalogIn ain(A0); -DigitalOut myled_R(LED_RED); // LED_RED on WIZwiki-W7500 +DigitalOut myled_R(LED_RED); + +AnalogIn ain(A0); + int main(void) { @@ -14,15 +15,21 @@ ain_val = ain.read()*1000; - // compare with specific value - if(ain_val > 500) myled_R = 1; // Red LED OFF - else myled_R = 0; // Red LED ON + // Compare between 'Specific value' and 'Analog Input value' + if(ain_val > 500) + { + myled_R = 1; // Red LED OFF + } + else + { + myled_R = 0; // Red LED ON + } // output the voltage and analog values printf("======================\r\n"); - printf("voltage value : %3.3f\r\n", ain.read()*3.3f); - printf("analog value : %3.3f\r\n", ain.read()); - printf("analog value x1000 : %d\r\n",ain_val); + printf("voltage value : %3.3f\r\n", ain.read()*3.3f); // voltage 0.0V ~ 3.3V + printf("analog value : %3.3f\r\n", ain.read()); // analog value 0.0 ~ 1.0 + printf("analog value x1000 : %d\r\n",ain_val); // analog value 0 ~ 1000 wait(1.0); } }