mbed_tt fork

Dependencies:   mbed

Fork of LM61 by jim hamblen

Committer:
kirthigaannamalai
Date:
Wed Jan 14 07:28:45 2015 +0000
Revision:
1:f7f1edaa8d90
Parent:
0:e035f4506cd7
new blinking pattern

Who changed what in which revision?

UserRevisionLine numberNew contents of line
4180_1 0:e035f4506cd7 1 #include "mbed.h"
4180_1 0:e035f4506cd7 2
4180_1 0:e035f4506cd7 3 //Print temperature from LM61 analog temperature sensor
4180_1 0:e035f4506cd7 4
4180_1 0:e035f4506cd7 5 //set p15 to analog input to read LM61 sensor's voltage output
4180_1 0:e035f4506cd7 6 AnalogIn LM61(p15);
4180_1 0:e035f4506cd7 7
4180_1 0:e035f4506cd7 8 //also setting unused analog input pins to digital outputs reduces A/D noise a bit
4180_1 0:e035f4506cd7 9 //see http://mbed.org/users/chris/notebook/Getting-best-ADC-performance/
4180_1 0:e035f4506cd7 10 DigitalOut P16(p16);
kirthigaannamalai 1:f7f1edaa8d90 11 DigitalOut myled(LED1);
kirthigaannamalai 1:f7f1edaa8d90 12 DigitalOut myled2(LED2);
kirthigaannamalai 1:f7f1edaa8d90 13
4180_1 0:e035f4506cd7 14
4180_1 0:e035f4506cd7 15 int main()
4180_1 0:e035f4506cd7 16 {
4180_1 0:e035f4506cd7 17 float tempC, tempF;
4180_1 0:e035f4506cd7 18
4180_1 0:e035f4506cd7 19 while(1) {
4180_1 0:e035f4506cd7 20 //conversion to degrees C - from sensor output voltage per LM61 data sheet
4180_1 0:e035f4506cd7 21 tempC = ((LM61*3.3)-0.600)*100.0;
4180_1 0:e035f4506cd7 22 //convert to degrees F
4180_1 0:e035f4506cd7 23 tempF = (9.0*tempC)/5.0 + 32.0;
4180_1 0:e035f4506cd7 24 //print current temp
4180_1 0:e035f4506cd7 25 printf("%5.2F C %5.2F F \n\r", tempC, tempF);
4180_1 0:e035f4506cd7 26 wait(.5);
kirthigaannamalai 1:f7f1edaa8d90 27 if(tempF=75)
kirthigaannamalai 1:f7f1edaa8d90 28 {
kirthigaannamalai 1:f7f1edaa8d90 29 myled = 1;
kirthigaannamalai 1:f7f1edaa8d90 30 myled2=0;
kirthigaannamalai 1:f7f1edaa8d90 31 wait(0.5);
kirthigaannamalai 1:f7f1edaa8d90 32 }
kirthigaannamalai 1:f7f1edaa8d90 33 else
kirthigaannamalai 1:f7f1edaa8d90 34 {
kirthigaannamalai 1:f7f1edaa8d90 35 myled = 0;
kirthigaannamalai 1:f7f1edaa8d90 36 myled2=1;
kirthigaannamalai 1:f7f1edaa8d90 37 wait(0.5);
kirthigaannamalai 1:f7f1edaa8d90 38 }
4180_1 0:e035f4506cd7 39 }
4180_1 0:e035f4506cd7 40 }