arito kadai2

Dependencies:   mbed

Committer:
arito
Date:
Fri Jul 20 04:40:35 2018 +0000
Revision:
0:9fd31ece983a
kadai2 arito

Who changed what in which revision?

UserRevisionLine numberNew contents of line
arito 0:9fd31ece983a 1 #include "mbed.h"
arito 0:9fd31ece983a 2
arito 0:9fd31ece983a 3 AnalogIn analog_value(dp13);
arito 0:9fd31ece983a 4 PwmOut led(dp24);
arito 0:9fd31ece983a 5
arito 0:9fd31ece983a 6 int main(void)
arito 0:9fd31ece983a 7 {
arito 0:9fd31ece983a 8 float meas, temp;
arito 0:9fd31ece983a 9 printf("\r\nAnalogIn example\r\n");
arito 0:9fd31ece983a 10 while(1) {
arito 0:9fd31ece983a 11 meas = analog_value.read(); // Converts and read the analog input value (value from 0.0 to 1.0)
arito 0:9fd31ece983a 12 meas = meas * 3300; // Change the value to be in the 0 to 3300 range (mV)
arito 0:9fd31ece983a 13 temp = 0.1 * meas - 50;
arito 0:9fd31ece983a 14 if( temp > 15.0){
arito 0:9fd31ece983a 15 led = 1;
arito 0:9fd31ece983a 16 led.period(4.0f);
arito 0:9fd31ece983a 17 led.write(0.5f);
arito 0:9fd31ece983a 18 }
arito 0:9fd31ece983a 19 else{
arito 0:9fd31ece983a 20 led = 0;
arito 0:9fd31ece983a 21 wait(1.0);
arito 0:9fd31ece983a 22 }
arito 0:9fd31ece983a 23 printf("measure = %.0f mV, temp = %.1f C\r\n", meas, temp);
arito 0:9fd31ece983a 24 wait(0.2); // 200 ms
arito 0:9fd31ece983a 25 }
arito 0:9fd31ece983a 26 }