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.
EnterTheGame.cpp
00001 #include "mbed.h" 00002 //************************ Complete to Interface *************************** 00003 // configure library with this code **************************************** 00004 SPI dot_matrix(D11,NC,D13); //mosi miso sclk 00005 DigitalOut lat(PA_12); //6 00006 DigitalOut sb(PA_11); //7 00007 DigitalOut rst(D10); 00008 BusOut open_line(D2,D3,D4,D5,D6,D7,D8,D9); 00009 //c0 c1 c2 c3 c4 c5 c6 c7 dont foget d7 00010 Serial pc(D1, D0); 00011 Timer t; 00012 00013 int counter; 00014 int click = 0; 00015 int swap = 0; 00016 int downter = 60; 00017 uint8_t rgb[3] = {0,0,0}; 00018 00019 00020 int main(){ 00021 00022 dot_matrix.frequency(1000000); 00023 // dot_matrix.format(6,0); 00024 uint8_t wb[3] = {255,255,255}; 00025 uint8_t pic[130][8] = { 00026 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00027 {0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00028 {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00029 {0x01,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00030 {0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00031 {0x03,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00032 {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00033 {0x07,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00034 {0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00035 {0x0f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00036 {0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00037 {0x1f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00038 {0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00039 {0x3f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00040 {0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00041 {0x7f,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00042 {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00043 {0xff,0x00,0x00,0x00,0x00,0x00,0x00,0x00}, 00044 {0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00}, 00045 {0xff,0x80,0x00,0x00,0x00,0x00,0x00,0x00}, 00046 {0xff,0x80,0x80,0x00,0x00,0x00,0x00,0x00}, 00047 {0xff,0x80,0x80,0x00,0x00,0x00,0x00,0x00}, 00048 {0xff,0x80,0x80,0x80,0x00,0x00,0x00,0x00}, 00049 {0xff,0x80,0x80,0x80,0x00,0x00,0x00,0x00}, 00050 {0xff,0x80,0x80,0x80,0x80,0x00,0x00,0x00}, 00051 {0xff,0x80,0x80,0x80,0x80,0x00,0x00,0x00}, 00052 {0xff,0x80,0x80,0x80,0x80,0x80,0x00,0x00}, 00053 {0xff,0x80,0x80,0x80,0x80,0x80,0x00,0x00}, 00054 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x00}, 00055 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x00}, 00056 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, 00057 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0x80}, 00058 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xc0}, 00059 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xc0}, 00060 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xe0}, 00061 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xe0}, 00062 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf0}, 00063 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf0}, 00064 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf8}, 00065 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xf8}, 00066 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfc}, 00067 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfc}, 00068 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfe}, 00069 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xfe}, 00070 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xff}, 00071 {0xff,0x80,0x80,0x80,0x80,0x80,0x80,0xff}, 00072 {0xff,0x80,0x80,0x80,0x80,0x80,0x81,0xff}, 00073 {0xff,0x80,0x80,0x80,0x80,0x80,0x81,0xff}, 00074 {0xff,0x80,0x80,0x80,0x80,0x81,0x81,0xff}, 00075 {0xff,0x80,0x80,0x80,0x80,0x81,0x81,0xff}, 00076 {0xff,0x80,0x80,0x80,0x81,0x81,0x81,0xff}, 00077 {0xff,0x80,0x80,0x80,0x81,0x81,0x81,0xff}, 00078 {0xff,0x80,0x80,0x81,0x81,0x81,0x81,0xff}, 00079 {0xff,0x80,0x80,0x81,0x81,0x81,0x81,0xff}, 00080 {0xff,0x80,0x81,0x81,0x81,0x81,0x81,0xff}, 00081 {0xff,0x80,0x81,0x81,0x81,0x81,0x81,0xff}, 00082 {0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff}, 00083 {0xff,0x81,0x81,0x81,0x81,0x81,0x81,0xff}, 00084 {0xff,0x83,0x81,0x81,0x81,0x81,0x81,0xff}, 00085 {0xff,0x83,0x81,0x81,0x81,0x81,0x81,0xff}, 00086 {0xff,0x87,0x81,0x81,0x81,0x81,0x81,0xff}, 00087 {0xff,0x87,0x81,0x81,0x81,0x81,0x81,0xff}, 00088 {0xff,0x8f,0x81,0x81,0x81,0x81,0x81,0xff}, 00089 {0xff,0x8f,0x81,0x81,0x81,0x81,0x81,0xff}, 00090 {0xff,0x9f,0x81,0x81,0x81,0x81,0x81,0xff}, 00091 {0xff,0x9f,0x81,0x81,0x81,0x81,0x81,0xff}, 00092 {0xff,0xbf,0x81,0x81,0x81,0x81,0x81,0xff}, 00093 {0xff,0xbf,0x81,0x81,0x81,0x81,0x81,0xff}, 00094 {0xff,0xff,0x81,0x81,0x81,0x81,0x81,0xff}, 00095 {0xff,0xff,0x81,0x81,0x81,0x81,0x81,0xff}, 00096 {0xff,0xff,0xc1,0x81,0x81,0x81,0x81,0xff}, 00097 {0xff,0xff,0xc1,0x81,0x81,0x81,0x81,0xff}, 00098 {0xff,0xff,0xc1,0xc1,0x81,0x81,0x81,0xff}, 00099 {0xff,0xff,0xc1,0xc1,0x81,0x81,0x81,0xff}, 00100 {0xff,0xff,0xc1,0xc1,0xc1,0x81,0x81,0xff}, 00101 {0xff,0xff,0xc1,0xc1,0xc1,0x81,0x81,0xff}, 00102 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0x81,0xff}, 00103 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0x81,0xff}, 00104 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xc1,0xff}, 00105 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xc1,0xff}, 00106 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xe1,0xff}, 00107 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xe1,0xff}, 00108 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf1,0xff}, 00109 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf1,0xff}, 00110 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf9,0xff}, 00111 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xf9,0xff}, 00112 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xfd,0xff}, 00113 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xfd,0xff}, 00114 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xff,0xff}, 00115 {0xff,0xff,0xc1,0xc1,0xc1,0xc1,0xff,0xff}, 00116 {0xff,0xff,0xc1,0xc1,0xc1,0xc3,0xff,0xff}, 00117 {0xff,0xff,0xc1,0xc1,0xc1,0xc3,0xff,0xff}, 00118 {0xff,0xff,0xc1,0xc1,0xc3,0xc3,0xff,0xff}, 00119 {0xff,0xff,0xc1,0xc1,0xc3,0xc3,0xff,0xff}, 00120 {0xff,0xff,0xc1,0xc3,0xc3,0xc3,0xff,0xff}, 00121 {0xff,0xff,0xc1,0xc3,0xc3,0xc3,0xff,0xff}, 00122 {0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0xff}, 00123 {0xff,0xff,0xc3,0xc3,0xc3,0xc3,0xff,0xff}, 00124 {0xff,0xff,0xc7,0xc3,0xc3,0xc3,0xff,0xff}, 00125 {0xff,0xff,0xc7,0xc3,0xc3,0xc3,0xff,0xff}, 00126 {0xff,0xff,0xcf,0xc3,0xc3,0xc3,0xff,0xff}, 00127 {0xff,0xff,0xcf,0xc3,0xc3,0xc3,0xff,0xff}, 00128 {0xff,0xff,0xdf,0xc3,0xc3,0xc3,0xff,0xff}, 00129 {0xff,0xff,0xdf,0xc3,0xc3,0xc3,0xff,0xff}, 00130 {0xff,0xff,0xff,0xc3,0xc3,0xc3,0xff,0xff}, 00131 {0xff,0xff,0xff,0xc3,0xc3,0xc3,0xff,0xff}, 00132 {0xff,0xff,0xff,0xe3,0xc3,0xc3,0xff,0xff}, 00133 {0xff,0xff,0xff,0xe3,0xc3,0xc3,0xff,0xff}, 00134 {0xff,0xff,0xff,0xe3,0xe3,0xc3,0xff,0xff}, 00135 {0xff,0xff,0xff,0xe3,0xe3,0xc3,0xff,0xff}, 00136 {0xff,0xff,0xff,0xe3,0xe3,0xe3,0xff,0xff}, 00137 {0xff,0xff,0xff,0xe3,0xe3,0xe3,0xff,0xff}, 00138 {0xff,0xff,0xff,0xe3,0xe3,0xf3,0xff,0xff}, 00139 {0xff,0xff,0xff,0xe3,0xe3,0xf3,0xff,0xff}, 00140 {0xff,0xff,0xff,0xe3,0xe3,0xfb,0xff,0xff}, 00141 {0xff,0xff,0xff,0xe3,0xe3,0xfb,0xff,0xff}, 00142 {0xff,0xff,0xff,0xe3,0xe3,0xff,0xff,0xff}, 00143 {0xff,0xff,0xff,0xe3,0xe3,0xff,0xff,0xff}, 00144 {0xff,0xff,0xff,0xe3,0xe7,0xff,0xff,0xff}, 00145 {0xff,0xff,0xff,0xe3,0xe7,0xff,0xff,0xff}, 00146 {0xff,0xff,0xff,0xe7,0xe7,0xff,0xff,0xff}, 00147 {0xff,0xff,0xff,0xe7,0xe7,0xff,0xff,0xff}, 00148 {0xff,0xff,0xff,0xef,0xe7,0xff,0xff,0xff}, 00149 {0xff,0xff,0xff,0xef,0xe7,0xff,0xff,0xff}, 00150 {0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff}, 00151 {0xff,0xff,0xff,0xff,0xe7,0xff,0xff,0xff}, 00152 {0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xff}, 00153 {0xff,0xff,0xff,0xff,0xf7,0xff,0xff,0xff}, 00154 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff}, 00155 {0xff,0xff,0xff,0xff,0xff,0xff,0xff,0xff} 00156 }; 00157 uint8_t temp; 00158 int line[8] = {1,2,4,8,16,32,64,128}; 00159 00160 rst = 1; 00161 wait(0.5); 00162 rst = 0; 00163 wait(0.5); 00164 rst = 1; 00165 wait(0.5); 00166 00167 //dot_matrix.format(6,0); 00168 sb = 0; // 6 bit 00169 for(int i = 0; i<8; i++){ 00170 dot_matrix.write(wb[0]); 00171 dot_matrix.write(wb[1]); 00172 dot_matrix.write(wb[2]); 00173 00174 open_line = 0; 00175 // dot_matrix.format(8,0); 00176 sb = 1; // 8 bit 00177 t.start(); 00178 while (1) { 00179 00180 for(int j=0;j<=130;j++){ 00181 swap = swap + 1; 00182 for(int a=0;a<=8;a++){ 00183 temp = pic[j][a]; 00184 counter = counter+1; 00185 if( counter == 60 ){ 00186 click = click+1; 00187 counter=0; 00188 } 00189 if(click == 0){ 00190 rgb[0] = 0; 00191 rgb[1] = 0; 00192 rgb[2] = counter; 00193 } 00194 else if(click == 1){ 00195 rgb[0] = 0; 00196 rgb[1] = counter; 00197 rgb[2] = 60; 00198 } 00199 else if(click == 2){ 00200 rgb[0] = 0; 00201 rgb[1] = 60; 00202 rgb[2] = 60 - counter; 00203 } 00204 else if(click == 3){ 00205 rgb[0] = counter; 00206 rgb[1] = 60; 00207 rgb[2] = 0; 00208 } 00209 else if(click == 4){ 00210 rgb[0] = 60; 00211 rgb[1] = 60 - counter; 00212 rgb[2] = 0; 00213 } 00214 else if(click == 5){ 00215 rgb[0] = 60; 00216 rgb[1] = 0; 00217 rgb[2] = counter; 00218 } 00219 else if(click == 6){ 00220 rgb[0] = 60 - counter; 00221 rgb[1] = 0; 00222 rgb[2] = 60; 00223 } 00224 else if(click == 7){ 00225 rgb[0] = 0; 00226 rgb[1] = 0; 00227 rgb[2] = 60; 00228 click = 1; 00229 } 00230 wait(0.001); 00231 for(int i = 0; i<8; i++){ 00232 00233 if(temp & 0x80){ 00234 dot_matrix.write(rgb[0]); 00235 dot_matrix.write(rgb[1]); 00236 dot_matrix.write(rgb[2]); 00237 } 00238 else{ 00239 dot_matrix.write(0); 00240 dot_matrix.write(0); 00241 dot_matrix.write(0); 00242 } 00243 temp = temp << 1; 00244 } 00245 lat = 1; 00246 lat = 0; 00247 open_line = line[a]; 00248 wait(0.001); 00249 } 00250 } 00251 00252 for(int j=129 ; j>=0;j--){ 00253 swap = swap + 1; 00254 for(int a=0;a<=8;a++){ 00255 temp = pic[j][a]; 00256 counter = counter+1; 00257 if( counter == 60 ){ 00258 click = click+1; 00259 counter=0; 00260 } 00261 if(click == 0){ 00262 rgb[0] = 0; 00263 rgb[1] = 0; 00264 rgb[2] = counter; 00265 } 00266 else if(click == 1){ 00267 rgb[0] = 0; 00268 rgb[1] = counter; 00269 rgb[2] = 60; 00270 } 00271 else if(click == 2){ 00272 rgb[0] = 0; 00273 rgb[1] = 60; 00274 rgb[2] = 60 - counter; 00275 } 00276 else if(click == 3){ 00277 rgb[0] = counter; 00278 rgb[1] = 60; 00279 rgb[2] = 0; 00280 } 00281 else if(click == 4){ 00282 rgb[0] = 60; 00283 rgb[1] = 60 - counter; 00284 rgb[2] = 0; 00285 } 00286 else if(click == 5){ 00287 rgb[0] = 60; 00288 rgb[1] = 0; 00289 rgb[2] = counter; 00290 } 00291 else if(click == 6){ 00292 rgb[0] = 60 - counter; 00293 rgb[1] = 0; 00294 rgb[2] = 60; 00295 } 00296 else if(click == 7){ 00297 rgb[0] = 0; 00298 rgb[1] = 0; 00299 rgb[2] = 60; 00300 click = 1; 00301 } 00302 wait(0.001); 00303 00304 00305 00306 for(int i = 0; i<8; i++){ 00307 00308 if(temp & 0x80){ 00309 dot_matrix.write(rgb[0]); 00310 dot_matrix.write(rgb[1]); 00311 dot_matrix.write(rgb[2]); 00312 } 00313 else{ 00314 dot_matrix.write(0); 00315 dot_matrix.write(0); 00316 dot_matrix.write(0); 00317 } 00318 temp = temp << 1; 00319 } 00320 lat = 1; 00321 lat = 0; 00322 open_line = line[a]; 00323 wait(0.001); 00324 } 00325 } 00326 00327 //open_line = 0; 00328 00329 } 00330 } 00331 }
Generated on Thu Jul 14 2022 05:16:54 by
1.7.2