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:
- 7:6b50af097b44
- Parent:
- 6:885e2cb16d7d
- Child:
- 8:bc6291805741
diff -r 885e2cb16d7d -r 6b50af097b44 main.cpp --- a/main.cpp Tue Aug 04 06:46:01 2015 +0000 +++ b/main.cpp Wed Jan 06 07:27:52 2016 +0000 @@ -8,20 +8,21 @@ int main(void) { - while (1) { + int ain_val = 0; - // If greater than 0.5 * VCC set the digital pin - // to a logic 1 otherwise a logic 0 - if(ain > 0.5f) { - myled_R = 1; // Red LED ON - } else { - myled_R = 0; // Red LED OFF - } + while (1) { + + 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 // 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); wait(1.0); } }