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.
Dependencies: 4DGL-uLCD-SE Joystick SDFileSystem mbed wave_player
Fork of 4180Lab4SimonSays by
main.cpp
00001 #include "mbed.h" 00002 #include "SDFileSystem.h" 00003 #include "uLCD_4DGL.h" 00004 #include "wave_player.h" 00005 #include "Joystick.h" 00006 00007 00008 Nav_Switch myNav( p9, p12, p13, p11, p10); // U, D, L, R, Fire 00009 uLCD_4DGL uLCD(p28, p27, p29); 00010 SDFileSystem sd(p5, p6, p7, p8, "sd"); //SD card 00011 00012 int arrowVec[20]; 00013 00014 00015 int arrow; 00016 00017 void mainMenu() { 00018 uLCD.baudrate(BAUD_3000000); 00019 while(1){ 00020 uLCD.locate(3,2); 00021 uLCD.puts("Simon Says"); 00022 uLCD.locate(3,6); 00023 uLCD.puts("Start"); 00024 if(myNav.fire()) { 00025 uLCD.cls(); 00026 return; 00027 } 00028 } 00029 } 00030 void createArrows(int lev) { 00031 00032 for (int i = 0; i < lev; i++) { 00033 if (arrowVec[i] == 1) { 00034 uLCD.cls(); 00035 //uLCD.background_color(DGREY); 00036 uLCD.triangle(15, 50, 35, 45, 35, 75, RED); 00037 uLCD.filled_rectangle(35,50,85,70,RED); 00038 //wait(.2); 00039 } else if (arrowVec[i] == 2) { 00040 uLCD.cls(); 00041 //uLCD.triangle(int x1, int y1 , int x2, int y2, int x3, int y3, RED); 00042 uLCD.filled_rectangle(70,35,50,85,BLUE); 00043 00044 } else if (arrowVec[i] == 3) { 00045 uLCD.cls(); 00046 //uLCD.triangle(); 00047 uLCD.filled_rectangle(85,70,35,50,GREEN); 00048 } else { 00049 uLCD.cls(); 00050 uLCD.filled_rectangle(50,85,70,35,WHITE); 00051 } 00052 wait(0.2); 00053 } 00054 } 00055 00056 00057 int main() { 00058 bool game = true; 00059 int level = 0; 00060 //int arrowVec[20]; 00061 //void mainMenu(); 00062 00063 00064 while(game) { 00065 level++; 00066 for (int i = 0; i < level; i++) { 00067 arrow = (rand() % 4) + 1; 00068 arrowVec[i] = arrow; 00069 } 00070 //arrowVec[0] = 1; 00071 createArrows(level); 00072 if(level==21){ 00073 game = false; 00074 } 00075 } 00076 00077 00078 }
Generated on Sat Jul 30 2022 12:05:38 by
1.7.2
