Temp36 HelloWorld Example for WIZwiki-W7500

Dependencies:   mbed

Fork of AnalogIn_HelloWorld_WIZwiki-W7500 by IOP

main.cpp

Committer:
IOP
Date:
2015-07-24
Revision:
6:0bbd259454d0
Parent:
5:2b825fae647d
Child:
8:7be9fa8531b5

File content as of revision 6:0bbd259454d0:

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

// Initialize a pins to perform analog input fucntions
AnalogIn   ain(A0); // connect A0(WIZwiki-W7500) to Vout(Temp36)

int main(void)
{
    while (1)
    {
        float V = ain.read() * 3.3;           // connect Vs(Temp36) to 3.3V(WIZwiki-W7500) 
        //float V = ain.read() * 5;           // connect Vs(Temp36) to 5V(WIZwiki-W7500)
        
        float tempC = (V-0.5) * 100;          // calculate temperature C
        float tempF = (tempC * 9 / 5) + 32.0; // calculate temperature F
        
        printf("tempC value : %5.2f C \r\n", tempC);
        printf("tempF value : %5.2f F \r\n", tempF);
        
        wait(1.0);
    }
}