jongrock chun / Mbed 2 deprecated For_test_code

Dependencies:   mbed

Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by IOP

Committer:
IOP
Date:
Tue Aug 04 06:46:01 2015 +0000
Revision:
6:885e2cb16d7d
Parent:
5:97fa889845b0
Child:
7:6b50af097b44
pin porting changed and med-src -> mbed

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
joon874 3:abab0082e271 6 AnalogIn ain(A0);
IOP 6:885e2cb16d7d 7 DigitalOut myled_R(LED_RED); // LED_RED on WIZwiki-W7500
sam_grove 0:101a12a915c6 8
sam_grove 0:101a12a915c6 9 int main(void)
IOP 6:885e2cb16d7d 10 {
sam_grove 0:101a12a915c6 11 while (1) {
IOP 5:97fa889845b0 12
IOP 6:885e2cb16d7d 13 // If greater than 0.5 * VCC set the digital pin
sam_grove 0:101a12a915c6 14 // to a logic 1 otherwise a logic 0
IOP 5:97fa889845b0 15 if(ain > 0.5f) {
IOP 5:97fa889845b0 16 myled_R = 1; // Red LED ON
sam_grove 0:101a12a915c6 17 } else {
IOP 5:97fa889845b0 18 myled_R = 0; // Red LED OFF
sam_grove 0:101a12a915c6 19 }
sam_grove 0:101a12a915c6 20
IOP 5:97fa889845b0 21 // output the voltage and analog values
IOP 6:885e2cb16d7d 22 printf("======================\r\n");
IOP 5:97fa889845b0 23 printf("voltage value : %3.3f\r\n", ain.read()*3.3f);
joon874 2:5f564266c94f 24 printf("analog value : %3.3f\r\n", ain.read());
joon874 2:5f564266c94f 25 wait(1.0);
sam_grove 0:101a12a915c6 26 }
sam_grove 0:101a12a915c6 27 }
joon874 3:abab0082e271 28
joon874 3:abab0082e271 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