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 Timer t; 00005 00006 DigitalOut led1(LED_BLUE); 00007 DigitalOut led2(LED_RED); 00008 TextLCD lcd(PTB10, PTB11, PTE2, PTE3, PTE4, PTE5); // rs, e, d4-d7 00009 00010 Serial wire(PTD3,PTD2); 00011 Serial xbee2(PTC4, PTC3); 00012 DigitalOut rst2(PTC5); 00013 00014 00015 00016 int main() 00017 { 00018 00019 //initiating lcd and xbee reset 00020 00021 lcd.cls(); 00022 lcd.locate(0,0); 00023 lcd.printf("starting\n"); 00024 rst2 = 0; 00025 wait_ms(1); 00026 rst2 = 1; 00027 wait_ms(1); 00028 00029 00030 char alast = 0; 00031 char a = 0; 00032 00033 char typingflag; 00034 00035 int typingtime; 00036 00037 float timesitting; 00038 00039 led1 = 1; 00040 led2 = 1; 00041 typingflag=0; 00042 typingtime=0; 00043 00044 00045 while(1) { 00046 if (xbee2.readable() && wire.readable()) { 00047 00048 a = xbee2.getc(); 00049 lcd.putc(a); 00050 lcd.locate(0,1); 00051 lcd.printf("t=%f",t.read()); 00052 00053 typingflag=wire.getc(); 00054 lcd.locate(2,0); 00055 lcd.printf("%d", (int) typingflag); 00056 00057 if((int) typingflag == 1) 00058 { 00059 led1 = 0; 00060 typingtime++; 00061 wait(0.5); 00062 } 00063 00064 00065 if (a != alast) { 00066 if (a == '1') { 00067 t.start(); 00068 led1 = 0; 00069 } 00070 else { 00071 // if (alast == 1) { 00072 00073 t.stop(); 00074 led2 = 0; 00075 timesitting = t.read(); 00076 lcd.cls(); 00077 lcd.locate(0,0); 00078 lcd.printf("%d", typingtime); 00079 lcd.locate(0,1); 00080 lcd.printf("%f",timesitting); 00081 00082 00083 t.reset(); 00084 typingtime = 0; 00085 wait(3); 00086 } // terminate else 00087 } // terminate if (a != alast) 00088 00089 } // terminate if (xbee2.readable() && wire.readable()) 00090 00091 00092 00093 00094 alast = a; 00095 wait(0.8); 00096 lcd.cls(); 00097 led1 = 1; 00098 led2 = 1; 00099 } 00100 }
Generated on Mon Aug 1 2022 16:14:42 by
1.7.2