arito kadai2

Dependencies:   mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 
00003 AnalogIn analog_value(dp13);
00004 PwmOut led(dp24);
00005 
00006 int main(void)
00007 {
00008    float meas, temp;
00009    printf("\r\nAnalogIn example\r\n");
00010    while(1) {
00011        meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
00012        meas = meas * 3300; // Change the value to be in the 0 to 3300 range (mV)
00013        temp = 0.1 * meas - 50;
00014     if( temp > 15.0){
00015            led = 1;
00016            led.period(4.0f);
00017            led.write(0.5f);
00018            }
00019        else{
00020            led = 0;
00021            wait(1.0);
00022            }
00023        printf("measure = %.0f mV, temp = %.1f C\r\n", meas, temp);
00024        wait(0.2); // 200 ms
00025    }
00026    }