jongrock chun / Mbed 2 deprecated For_test_code

Dependencies:   mbed

Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by IOP

Committer:
IOP
Date:
Fri Jul 24 01:48:17 2015 +0000
Revision:
5:97fa889845b0
Parent:
3:abab0082e271
Child:
6:885e2cb16d7d
run with easy module shield

Who changed what in which revision?

UserRevisionLine numberNew contents of line
joon874 3:abab0082e271 1 /* Analog Input Example Program */
sam_grove 0:101a12a915c6 2
sam_grove 0:101a12a915c6 3 #include "mbed.h"
sam_grove 0:101a12a915c6 4
sam_grove 0:101a12a915c6 5 // Initialize a pins to perform analog input and digital output fucntions
IOP 5:97fa889845b0 6 DigitalOut shield_led_off(D10); // LED_GREEN on easy module shield
joon874 3:abab0082e271 7 AnalogIn ain(A0);
IOP 5:97fa889845b0 8 DigitalOut myled_R(D9); // LED_RED on easy module shield
sam_grove 0:101a12a915c6 9
sam_grove 0:101a12a915c6 10 int main(void)
sam_grove 0:101a12a915c6 11 {
IOP 5:97fa889845b0 12 shield_led_off = 0; // turn off Green LED on shield
IOP 5:97fa889845b0 13
sam_grove 0:101a12a915c6 14 while (1) {
IOP 5:97fa889845b0 15
IOP 5:97fa889845b0 16 // If greater than 0.4 * VCC set the digital pin
sam_grove 0:101a12a915c6 17 // to a logic 1 otherwise a logic 0
IOP 5:97fa889845b0 18 if(ain > 0.5f) {
IOP 5:97fa889845b0 19 myled_R = 1; // Red LED ON
sam_grove 0:101a12a915c6 20 } else {
IOP 5:97fa889845b0 21 myled_R = 0; // Red LED OFF
sam_grove 0:101a12a915c6 22 }
sam_grove 0:101a12a915c6 23
IOP 5:97fa889845b0 24 // output the voltage and analog values
IOP 5:97fa889845b0 25 printf("voltage value : %3.3f\r\n", ain.read()*3.3f);
joon874 2:5f564266c94f 26 printf("analog value : %3.3f\r\n", ain.read());
joon874 2:5f564266c94f 27 wait(1.0);
sam_grove 0:101a12a915c6 28 }
sam_grove 0:101a12a915c6 29 }
joon874 3:abab0082e271 30
joon874 3:abab0082e271 31
joon874 3:abab0082e271 32
joon874 3:abab0082e271 33
joon874 3:abab0082e271 34
joon874 3:abab0082e271 35
joon874 3:abab0082e271 36
joon874 3:abab0082e271 37
joon874 3:abab0082e271 38