LM35D Temperature Sensor use

Dependencies:   TextLCD mbed-rtos mbed

Fork of TextLCD_HelloWorld by Simon Ford

Revision:
3:4fb8133db562
Parent:
2:ad0b044d0a10
--- a/main.cpp	Sat Dec 04 11:31:07 2010 +0000
+++ b/main.cpp	Wed Mar 12 01:04:11 2014 +0000
@@ -1,10 +1,37 @@
-// Hello World! for the TextLCD
-
 #include "mbed.h"
 #include "TextLCD.h"
+#include "rtos.h"
 
-TextLCD lcd(p15, p16, p17, p18, p19, p20); // rs, e, d4-d7
+TextLCD lcd(p24, p26, p27, p28, p29, p30); // rs, e, d4-d7
+AnalogIn ain(p20);
+DigitalOut led(LED1);
+
+float Temp;
 
-int main() {
-    lcd.printf("Hello World!\n");
+void display(void const *n)
+{
+    static int num=0;
+    lcd.locate(0,0);
+    lcd.printf("Count %3d",num);
+    lcd.locate(0,1);
+    lcd.printf("Temp=%4.1f",Temp);
+    num++;
+    if(num>999)num=0;
 }
+
+void measure(void const *n)
+{
+    Temp=ain.read()*3.3*100;
+    led=!led;
+}
+
+int main()
+{
+    led=0;
+    lcd.cls();
+    RtosTimer measure_timer(measure);
+    RtosTimer display_timer(display);
+    measure_timer.start(2000);
+    display_timer.start(3000);
+    Thread::wait(osWaitForever);
+}