Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
main.cpp
00001 #include "mbed.h" 00002 #include "TextLCD.h" 00003 00004 00005 AnalogIn LM35(p15); 00006 TextLCD lcd (p21,p22,p23,p24,p25,p26);// rs, e, d4-d7 00007 DigitalIn PIR (p19);// 00008 DigitalOut myled (LED1); 00009 DigitalOut myled2 (LED2); 00010 00011 00012 00013 int main() 00014 { 00015 float tempC; 00016 00017 while(1) 00018 { 00019 lcd.cls(); 00020 lcd.locate(0,0); 00021 lcd.printf("Temperature:"); 00022 wait(0.5);//wait for 0.5s for the system, to detect 00023 lcd.cls(); 00024 wait(0.5); 00025 if (PIR==1) 00026 { 00027 tempC=LM35.read()*330; 00028 wait(0.2); 00029 lcd.locate(1,1); 00030 lcd.printf("%.2f deg",tempC); 00031 if(tempC>25) 00032 { 00033 myled=1; 00034 myled2=0; 00035 } 00036 else 00037 { 00038 myled2=1; 00039 myled=0; 00040 } 00041 wait(0.01); 00042 lcd.cls(); 00043 wait(0.5); 00044 } 00045 if(PIR==0) 00046 { 00047 lcd.locate(1,1); 00048 lcd.printf("no motion"); 00049 wait(0.004); 00050 lcd.cls(); 00051 wait(0.004); 00052 } 00053 } 00054 }
Generated on Sat Aug 20 2022 07:38:27 by
1.7.2