Temp36 HelloWorld Example for WIZwiki-W7500

Dependencies:   mbed

Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by IOP

main.cpp

Committer:
joon874
Date:
2015-07-02
Revision:
3:abab0082e271
Parent:
2:5f564266c94f
Child:
4:46410fc301ea

File content as of revision 3:abab0082e271:

/* Analog Input Example Program */
 
#include "mbed.h"

// Initialize a pins to perform analog input and digital output fucntions
AnalogIn   ain(A0);     
DigitalOut myled(LED1);     // on-board LED_RED

int main(void)
{
    while (1) {
        // test the voltage on the initialized analog pin
        //  and 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
        } else {
            myled = 0;      // Red LED On
        }
        
        // print the percentage and normalized values
        printf("percentage: %3.3f%%\r\n", ain.read()*100.0f);
        printf("analog value : %3.3f\r\n", ain.read());
        wait(1.0);
    }
}