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 "TSISensor.h" 00003 #include "TextLCD.h" 00004 00005 00006 00007 int hit=0; 00008 int lives=10; 00009 float a; 00010 TSISensor tsi; 00011 00012 DigitalOut Flash(PTC11); 00013 00014 00015 TextLCD lcd(PTD7, PTD6, PTA17, PTA16, PTC17, PTC16); // rs, e, d4-d7 00016 00017 00018 00019 00020 int main() 00021 00022 { 00023 Flash=1; 00024 lcd.cls(); 00025 00026 00027 while(1) 00028 { 00029 00030 while (lives>0) 00031 00032 { 00033 a=tsi.readPercentage(); 00034 00035 if (a>=0.01) 00036 {hit=1;} 00037 else 00038 {hit=0;} 00039 00040 lcd.locate(0,0); 00041 lcd.printf("Lives remaining: %d \n", lives); 00042 00043 00044 if (hit==1) 00045 { 00046 unsigned char i; 00047 00048 00049 lives--; 00050 00051 lcd.locate(0,0); 00052 lcd.printf("Lives remaining: %d \n", lives); 00053 00054 for(i=0;i<4;i++) 00055 { 00056 Flash=0; 00057 wait(0.2); 00058 Flash=1; 00059 wait(0.2); 00060 } 00061 } 00062 } 00063 00064 while (lives==0) 00065 { 00066 a=tsi.readPercentage(); 00067 00068 if (a>=0.01) 00069 {hit=1;} 00070 else 00071 {hit=0;} 00072 00073 lcd.locate(0,0); 00074 lcd.printf("Lives remaining: %d \n", lives); 00075 00076 00077 if (hit==1) 00078 { 00079 lives--; 00080 } 00081 } 00082 00083 00084 00085 lcd.cls(); 00086 lcd.locate(0,0); 00087 lcd.printf(" - GAME OVER - ...you suck"); 00088 00089 00090 unsigned char i; 00091 for(i=0;i<200;i++) 00092 { 00093 Flash=0; 00094 wait(0.05); 00095 Flash=1; 00096 wait(0.05); 00097 } 00098 00099 lcd.cls(); 00100 lives= 10; 00101 } 00102 }
Generated on Thu Jul 14 2022 00:43:44 by
1.7.2