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:
- 5:97fa889845b0
- Parent:
- 3:abab0082e271
- Child:
- 6:885e2cb16d7d
--- a/main.cpp Fri Jul 10 05:46:58 2015 +0000 +++ b/main.cpp Fri Jul 24 01:48:17 2015 +0000 @@ -3,23 +3,26 @@ #include "mbed.h" // Initialize a pins to perform analog input and digital output fucntions +DigitalOut shield_led_off(D10); // LED_GREEN on easy module shield AnalogIn ain(A0); -DigitalOut myled(LED1); // on-board LED_RED +DigitalOut myled_R(D9); // LED_RED on easy module shield int main(void) { + shield_led_off = 0; // turn off Green LED on shield + while (1) { - // test the voltage on the initialized analog pin - // and if greater than 0.4 * VCC set the digital pin + + // If greater than 0.4 * VCC set the digital pin // to a logic 1 otherwise a logic 0 - if(ain > 0.4f) { - myled = 1; // Red LED Off + if(ain > 0.5f) { + myled_R = 1; // Red LED ON } else { - myled = 0; // Red LED On + myled_R = 0; // Red LED OFF } - // print the percentage and normalized values - printf("percentage: %3.3f%%\r\n", ain.read()*100.0f); + // output the voltage and analog values + printf("voltage value : %3.3f\r\n", ain.read()*3.3f); printf("analog value : %3.3f\r\n", ain.read()); wait(1.0); }