KENJI LEE
/
microP-Tempcontrol
any error pls help me debug!!!! lCD will show other word
Diff: main.cpp
- Revision:
- 0:810d1a280dc4
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Wed Dec 10 22:33:45 2014 +0000 @@ -0,0 +1,54 @@ +#include "mbed.h" +#include "TextLCD.h" + + +AnalogIn LM35(p15); +TextLCD lcd (p21,p22,p23,p24,p25,p26);// rs, e, d4-d7 +DigitalIn PIR (p19);// +DigitalOut myled (LED1); +DigitalOut myled2 (LED2); + + + +int main() +{ + float tempC; + + while(1) + { + lcd.cls(); + lcd.locate(0,0); + lcd.printf("Temperature:"); + wait(0.5);//wait for 0.5s for the system, to detect + lcd.cls(); + wait(0.5); + if (PIR==1) + { + tempC=LM35.read()*330; + wait(0.2); + lcd.locate(1,1); + lcd.printf("%.2f deg",tempC); + if(tempC>25) + { + myled=1; + myled2=0; + } + else + { + myled2=1; + myled=0; + } + wait(0.01); + lcd.cls(); + wait(0.5); + } + if(PIR==0) + { + lcd.locate(1,1); + lcd.printf("no motion"); + wait(0.004); + lcd.cls(); + wait(0.004); + } +} +} \ No newline at end of file