Simon: A Memory Game

Dependencies:   4DGL-uLCD-SE PinDetect mbed

Committer:
cmathis
Date:
Tue Oct 21 15:29:16 2014 +0000
Revision:
2:c92f0e749b94
Parent:
1:cd222334a4fe
revision3

Who changed what in which revision?

UserRevisionLine numberNew contents of line
cmathis 0:64ea583d77e2 1 /*********************************/
cmathis 0:64ea583d77e2 2 // ECE 4180 Lab 4
cmathis 0:64ea583d77e2 3 // Colton Mathis, Taylor Hawley
cmathis 0:64ea583d77e2 4 /*********************************/
cmathis 0:64ea583d77e2 5
cmathis 0:64ea583d77e2 6 #include "mbed.h"
cmathis 0:64ea583d77e2 7 #include "uLCD_4DGL.h"
cmathis 0:64ea583d77e2 8 #include "PinDetect.h"
cmathis 0:64ea583d77e2 9 #include "Speaker.h"
cmathis 0:64ea583d77e2 10
cmathis 0:64ea583d77e2 11 // pushbutton interrupts with debounce
cmathis 0:64ea583d77e2 12 PinDetect pb1(p25, PullUp);
cmathis 0:64ea583d77e2 13 PinDetect pb2(p26, PullUp);
cmathis 0:64ea583d77e2 14 PinDetect pb3(p23, PullUp);
cmathis 0:64ea583d77e2 15 PinDetect pb4(p24, PullUp);
cmathis 0:64ea583d77e2 16
cmathis 0:64ea583d77e2 17 // four LED outputs
cmathis 0:64ea583d77e2 18 DigitalOut led1(p7);
cmathis 0:64ea583d77e2 19 DigitalOut led2(p9);
cmathis 0:64ea583d77e2 20 DigitalOut led3(p8);
cmathis 0:64ea583d77e2 21 DigitalOut led4(p6);
cmathis 0:64ea583d77e2 22
cmathis 0:64ea583d77e2 23 // speaker object
cmathis 0:64ea583d77e2 24 Speaker mySpeaker(p21);
cmathis 0:64ea583d77e2 25
cmathis 0:64ea583d77e2 26 // LCD object
cmathis 0:64ea583d77e2 27 uLCD_4DGL uLCD(p28, p27, p29);
cmathis 0:64ea583d77e2 28
cmathis 0:64ea583d77e2 29 // analog input for seeding rand() function
cmathis 0:64ea583d77e2 30 AnalogIn adcReading(p18);
cmathis 2:c92f0e749b94 31 AnalogIn pot(p19);
cmathis 0:64ea583d77e2 32
cmathis 0:64ea583d77e2 33 // variable declarations
cmathis 0:64ea583d77e2 34 int levels[16];
cmathis 0:64ea583d77e2 35 int levelsIndex;
cmathis 0:64ea583d77e2 36 int level;
cmathis 0:64ea583d77e2 37 int buttonPressed;
cmathis 0:64ea583d77e2 38 int buttonPushes;
cmathis 0:64ea583d77e2 39 int failed;
cmathis 0:64ea583d77e2 40 int start = 1;
cmathis 0:64ea583d77e2 41 int randomSeed;
cmathis 2:c92f0e749b94 42 float volume;
cmathis 0:64ea583d77e2 43
cmathis 0:64ea583d77e2 44 // function prototypes
cmathis 0:64ea583d77e2 45 void enableInterrupts();
cmathis 0:64ea583d77e2 46 void disableInterrupts();
cmathis 0:64ea583d77e2 47 void startGame();
cmathis 0:64ea583d77e2 48 void setLevels();
cmathis 0:64ea583d77e2 49 void playSequence();
cmathis 0:64ea583d77e2 50 void pushOne();
cmathis 0:64ea583d77e2 51 void pushTwo();
cmathis 0:64ea583d77e2 52 void pushThree();
cmathis 0:64ea583d77e2 53 void pushFour();
cmathis 0:64ea583d77e2 54 void failedGame();
cmathis 0:64ea583d77e2 55 void endGame();
cmathis 0:64ea583d77e2 56
cmathis 0:64ea583d77e2 57 int main() {
cmathis 0:64ea583d77e2 58
cmathis 0:64ea583d77e2 59 // read in value from analog input as unsigned short instead of float
cmathis 0:64ea583d77e2 60 // and seed the rand() function with the value
cmathis 0:64ea583d77e2 61 randomSeed = adcReading.read_u16();
cmathis 0:64ea583d77e2 62 srand(randomSeed);
cmathis 0:64ea583d77e2 63 uLCD.baudrate(3000000);
cmathis 0:64ea583d77e2 64
cmathis 0:64ea583d77e2 65 while(1) {
cmathis 0:64ea583d77e2 66
cmathis 2:c92f0e749b94 67 volume = pot.read();
cmathis 2:c92f0e749b94 68
cmathis 0:64ea583d77e2 69 // only initialize these variables at the start of each game
cmathis 0:64ea583d77e2 70 if(start == 1){
cmathis 0:64ea583d77e2 71 failed = 0;
cmathis 0:64ea583d77e2 72 level = 0;
cmathis 0:64ea583d77e2 73 buttonPressed = 0;
cmathis 0:64ea583d77e2 74 buttonPushes = 0;
cmathis 0:64ea583d77e2 75 levelsIndex = 0;
cmathis 0:64ea583d77e2 76 startGame();
cmathis 0:64ea583d77e2 77 }
cmathis 0:64ea583d77e2 78 start = 0;
cmathis 0:64ea583d77e2 79
cmathis 0:64ea583d77e2 80 // generate and play the sequence of LEDs (and sounds) that the player copies
cmathis 0:64ea583d77e2 81 setLevels();
cmathis 0:64ea583d77e2 82 playSequence();
cmathis 0:64ea583d77e2 83
cmathis 0:64ea583d77e2 84 // enable the four pushbutton interrupts
cmathis 0:64ea583d77e2 85 enableInterrupts();
cmathis 0:64ea583d77e2 86
cmathis 0:64ea583d77e2 87 // wait in this loop until the user pushes buttons the same number of times as the current level
cmathis 0:64ea583d77e2 88 // or until the user has pushed an incorrect button
cmathis 0:64ea583d77e2 89 while(buttonPushes != level && failed == 0){
cmathis 2:c92f0e749b94 90 volume = pot.read();
cmathis 2:c92f0e749b94 91 wait(0.1);
cmathis 0:64ea583d77e2 92 }
cmathis 0:64ea583d77e2 93
cmathis 0:64ea583d77e2 94 // if the user has failed, disable the pushbutton interrupts, notify the user that they failed,
cmathis 0:64ea583d77e2 95 // and then set start=1 so that the game restarts from level 1
cmathis 0:64ea583d77e2 96 if(failed == 1){
cmathis 0:64ea583d77e2 97 disableInterrupts();
cmathis 0:64ea583d77e2 98 failedGame();
cmathis 0:64ea583d77e2 99 start = 1;
cmathis 0:64ea583d77e2 100 }
cmathis 0:64ea583d77e2 101
cmathis 0:64ea583d77e2 102 // if the user has completed all of the levels without failing, disable the pushbutton interrupts,
cmathis 0:64ea583d77e2 103 // notify the user that they won, and set start=1 so that the game restarts from level 1
cmathis 2:c92f0e749b94 104 if(level == 10 && failed == 0){
cmathis 0:64ea583d77e2 105 disableInterrupts();
cmathis 0:64ea583d77e2 106 endGame();
cmathis 0:64ea583d77e2 107 start = 1;
cmathis 0:64ea583d77e2 108 }
cmathis 0:64ea583d77e2 109
cmathis 0:64ea583d77e2 110 // if the user has not failed or completed all of the levels, disable the interrupts and continue
cmathis 0:64ea583d77e2 111 disableInterrupts();
cmathis 0:64ea583d77e2 112
cmathis 0:64ea583d77e2 113 // set buttonpushes=0 to record the button presses for the next level
cmathis 0:64ea583d77e2 114 buttonPushes = 0;
cmathis 0:64ea583d77e2 115
cmathis 0:64ea583d77e2 116 // wait a short amount of time before starting the next game
cmathis 0:64ea583d77e2 117 if(start==1){
cmathis 0:64ea583d77e2 118 wait(2);
cmathis 0:64ea583d77e2 119 }
cmathis 0:64ea583d77e2 120
cmathis 0:64ea583d77e2 121 }
cmathis 0:64ea583d77e2 122
cmathis 0:64ea583d77e2 123 }
cmathis 0:64ea583d77e2 124
cmathis 0:64ea583d77e2 125
cmathis 0:64ea583d77e2 126 void enableInterrupts(){
cmathis 0:64ea583d77e2 127
cmathis 0:64ea583d77e2 128 // set the four pushbutton interrupts to trigger on a falling edge
cmathis 0:64ea583d77e2 129 pb1.attach_deasserted(&pushOne);
cmathis 0:64ea583d77e2 130 pb2.attach_deasserted(&pushTwo);
cmathis 0:64ea583d77e2 131 pb3.attach_deasserted(&pushThree);
cmathis 0:64ea583d77e2 132 pb4.attach_deasserted(&pushFour);
cmathis 0:64ea583d77e2 133
cmathis 0:64ea583d77e2 134 // start the four interrupts (default sample frequency is 20ms)
cmathis 0:64ea583d77e2 135 pb1.setSampleFrequency();
cmathis 0:64ea583d77e2 136 pb2.setSampleFrequency();
cmathis 0:64ea583d77e2 137 pb3.setSampleFrequency();
cmathis 0:64ea583d77e2 138 pb4.setSampleFrequency();
cmathis 0:64ea583d77e2 139
cmathis 0:64ea583d77e2 140 }
cmathis 0:64ea583d77e2 141
cmathis 0:64ea583d77e2 142
cmathis 0:64ea583d77e2 143 void disableInterrupts(){
cmathis 0:64ea583d77e2 144
cmathis 0:64ea583d77e2 145 // disable four interrupts by setting their service routine to NULL pointer
cmathis 0:64ea583d77e2 146 pb1.attach_deasserted(NULL);
cmathis 0:64ea583d77e2 147 pb2.attach_deasserted(NULL);
cmathis 0:64ea583d77e2 148 pb3.attach_deasserted(NULL);
cmathis 0:64ea583d77e2 149 pb4.attach_deasserted(NULL);
cmathis 0:64ea583d77e2 150
cmathis 0:64ea583d77e2 151 }
cmathis 0:64ea583d77e2 152
cmathis 0:64ea583d77e2 153 // this function is called at the beginning of the game
cmathis 0:64ea583d77e2 154 void startGame(){
cmathis 0:64ea583d77e2 155
cmathis 0:64ea583d77e2 156 uLCD.cls();
cmathis 0:64ea583d77e2 157 uLCD.display_control(PORTRAIT);
cmathis 0:64ea583d77e2 158 uLCD.color(BLUE);
cmathis 0:64ea583d77e2 159 uLCD.text_width(2);
cmathis 0:64ea583d77e2 160 uLCD.text_height(2);
cmathis 0:64ea583d77e2 161 uLCD.locate(2, 3);
cmathis 0:64ea583d77e2 162 uLCD.printf("SIMON");
cmathis 0:64ea583d77e2 163
cmathis 1:cd222334a4fe 164 // start up LED/uLCD sequence
cmathis 0:64ea583d77e2 165 led1 = 1;
cmathis 0:64ea583d77e2 166 uLCD.filled_rectangle(0, 0, 63, 40, 0x00CC00);
cmathis 0:64ea583d77e2 167 wait(0.5);
cmathis 0:64ea583d77e2 168 led1 = 0;
cmathis 0:64ea583d77e2 169 uLCD.filled_rectangle(0, 0, 63, 40, 0x000000);
cmathis 0:64ea583d77e2 170
cmathis 0:64ea583d77e2 171 led2 = 1;
cmathis 0:64ea583d77e2 172 uLCD.filled_rectangle(64, 0, 127, 40, 0xFF0000);
cmathis 0:64ea583d77e2 173 wait(0.5);
cmathis 0:64ea583d77e2 174 led2 = 0;
cmathis 0:64ea583d77e2 175 uLCD.filled_rectangle(64, 0, 127, 40, 0x000000);
cmathis 0:64ea583d77e2 176
cmathis 0:64ea583d77e2 177 led3 = 1;
cmathis 0:64ea583d77e2 178 uLCD.filled_rectangle(64, 87, 127, 127, 0x0000FF);
cmathis 0:64ea583d77e2 179 wait(0.5);
cmathis 0:64ea583d77e2 180 led3 = 0;
cmathis 0:64ea583d77e2 181 uLCD.filled_rectangle(64, 87, 127, 127, 0x000000);
cmathis 0:64ea583d77e2 182
cmathis 0:64ea583d77e2 183 led4 = 1;
cmathis 0:64ea583d77e2 184 uLCD.filled_rectangle(0, 87, 63, 127, 0xCCCC00);
cmathis 0:64ea583d77e2 185 wait(0.5);
cmathis 0:64ea583d77e2 186 led4 = 0;
cmathis 0:64ea583d77e2 187 uLCD.filled_rectangle(0, 87, 63, 127, 0x000000);
cmathis 0:64ea583d77e2 188
cmathis 0:64ea583d77e2 189 wait(2);
cmathis 0:64ea583d77e2 190
cmathis 0:64ea583d77e2 191 uLCD.cls();
cmathis 0:64ea583d77e2 192
cmathis 0:64ea583d77e2 193 }
cmathis 0:64ea583d77e2 194
cmathis 0:64ea583d77e2 195
cmathis 0:64ea583d77e2 196 void setLevels(){
cmathis 0:64ea583d77e2 197
cmathis 0:64ea583d77e2 198 // "levels" array is a sequence of numbers 1-4 that determines which LEDs will light up
cmathis 0:64ea583d77e2 199 // during a given level --- grows by 1 value each level
cmathis 0:64ea583d77e2 200 level++;
cmathis 0:64ea583d77e2 201 levels[level-1] = rand()%4 + 1;
cmathis 0:64ea583d77e2 202
cmathis 1:cd222334a4fe 203 // display the current level on the uLCD
cmathis 0:64ea583d77e2 204 uLCD.color(BLUE);
cmathis 0:64ea583d77e2 205 uLCD.text_width(2);
cmathis 0:64ea583d77e2 206 uLCD.text_height(2);
cmathis 0:64ea583d77e2 207 uLCD.locate(2, 2);
cmathis 0:64ea583d77e2 208 uLCD.printf("Level");
cmathis 0:64ea583d77e2 209 uLCD.locate(4, 4);
cmathis 0:64ea583d77e2 210 uLCD.printf("%d", level);
cmathis 0:64ea583d77e2 211 wait(1);
cmathis 0:64ea583d77e2 212
cmathis 0:64ea583d77e2 213 }
cmathis 0:64ea583d77e2 214
cmathis 0:64ea583d77e2 215
cmathis 0:64ea583d77e2 216 void playSequence(){
cmathis 0:64ea583d77e2 217
cmathis 0:64ea583d77e2 218 // play the sequence of LEDs defined in the "levels" array along with the corresponding notes
cmathis 0:64ea583d77e2 219 for(int i = 0; i < level; i++){
cmathis 0:64ea583d77e2 220 switch(levels[i]){
cmathis 0:64ea583d77e2 221 case 1:
cmathis 0:64ea583d77e2 222 led1 = 1;
cmathis 2:c92f0e749b94 223 mySpeaker.PlayNote(659.26, 0.50, volume);
cmathis 0:64ea583d77e2 224 led1 = 0;
cmathis 0:64ea583d77e2 225 wait(0.025);
cmathis 0:64ea583d77e2 226 break;
cmathis 0:64ea583d77e2 227 case 2:
cmathis 0:64ea583d77e2 228 led2 = 1;
cmathis 2:c92f0e749b94 229 mySpeaker.PlayNote(554.00, 0.50, volume);
cmathis 0:64ea583d77e2 230 led2 = 0;
cmathis 0:64ea583d77e2 231 wait(0.025);
cmathis 0:64ea583d77e2 232 break;
cmathis 0:64ea583d77e2 233 case 3:
cmathis 0:64ea583d77e2 234 led3 = 1;
cmathis 2:c92f0e749b94 235 mySpeaker.PlayNote(440.00, 0.50, volume);
cmathis 0:64ea583d77e2 236 led3 = 0;
cmathis 0:64ea583d77e2 237 wait(0.025);
cmathis 0:64ea583d77e2 238 break;
cmathis 0:64ea583d77e2 239 case 4:
cmathis 0:64ea583d77e2 240 led4 = 1;
cmathis 2:c92f0e749b94 241 mySpeaker.PlayNote(329.63, 0.50, volume);
cmathis 0:64ea583d77e2 242 led4 = 0;
cmathis 0:64ea583d77e2 243 wait(0.025);
cmathis 0:64ea583d77e2 244 break;
cmathis 0:64ea583d77e2 245 default:
cmathis 0:64ea583d77e2 246 while(1){
cmathis 0:64ea583d77e2 247 led1 = !led1;
cmathis 0:64ea583d77e2 248 wait(0.5);
cmathis 0:64ea583d77e2 249 }
cmathis 0:64ea583d77e2 250 }
cmathis 0:64ea583d77e2 251 }
cmathis 0:64ea583d77e2 252
cmathis 0:64ea583d77e2 253 }
cmathis 0:64ea583d77e2 254
cmathis 0:64ea583d77e2 255 // ISR for pushbutton 1 interrupt
cmathis 0:64ea583d77e2 256 void pushOne(){
cmathis 0:64ea583d77e2 257
cmathis 0:64ea583d77e2 258 buttonPushes++;
cmathis 0:64ea583d77e2 259
cmathis 0:64ea583d77e2 260 led1 = 1;
cmathis 2:c92f0e749b94 261 mySpeaker.PlayNote(659.26, 0.25, volume);
cmathis 0:64ea583d77e2 262 led1 = 0;
cmathis 0:64ea583d77e2 263
cmathis 0:64ea583d77e2 264 if(levels[buttonPushes-1] != 1){
cmathis 0:64ea583d77e2 265 failed = 1;
cmathis 0:64ea583d77e2 266 }
cmathis 0:64ea583d77e2 267
cmathis 0:64ea583d77e2 268 }
cmathis 0:64ea583d77e2 269
cmathis 0:64ea583d77e2 270 // ISR for pushbutton 2 interrupt
cmathis 0:64ea583d77e2 271 void pushTwo(){
cmathis 0:64ea583d77e2 272
cmathis 0:64ea583d77e2 273 buttonPushes++;
cmathis 0:64ea583d77e2 274
cmathis 0:64ea583d77e2 275 led2 = 1;
cmathis 2:c92f0e749b94 276 mySpeaker.PlayNote(554.00, 0.25, volume);
cmathis 0:64ea583d77e2 277 led2 = 0;
cmathis 0:64ea583d77e2 278
cmathis 0:64ea583d77e2 279 if(levels[buttonPushes-1] != 2){
cmathis 0:64ea583d77e2 280 failed = 1;
cmathis 0:64ea583d77e2 281 }
cmathis 0:64ea583d77e2 282
cmathis 0:64ea583d77e2 283 }
cmathis 0:64ea583d77e2 284
cmathis 0:64ea583d77e2 285 // ISR for pushbutton 3 interrupt
cmathis 0:64ea583d77e2 286 void pushThree(){
cmathis 0:64ea583d77e2 287
cmathis 0:64ea583d77e2 288 buttonPushes++;
cmathis 0:64ea583d77e2 289
cmathis 0:64ea583d77e2 290 led3 = 1;
cmathis 2:c92f0e749b94 291 mySpeaker.PlayNote(440.00, 0.25, volume);
cmathis 0:64ea583d77e2 292 led3 = 0;
cmathis 0:64ea583d77e2 293
cmathis 0:64ea583d77e2 294 if(levels[buttonPushes-1] != 3){
cmathis 0:64ea583d77e2 295 failed = 1;
cmathis 0:64ea583d77e2 296 }
cmathis 0:64ea583d77e2 297
cmathis 0:64ea583d77e2 298 }
cmathis 0:64ea583d77e2 299
cmathis 0:64ea583d77e2 300 // ISR for pushbutton 4 interrupt
cmathis 0:64ea583d77e2 301 void pushFour(){
cmathis 0:64ea583d77e2 302
cmathis 0:64ea583d77e2 303 buttonPushes++;
cmathis 0:64ea583d77e2 304
cmathis 0:64ea583d77e2 305 led4 = 1;
cmathis 2:c92f0e749b94 306 mySpeaker.PlayNote(329.63, 0.25, volume);
cmathis 0:64ea583d77e2 307 led4 = 0;
cmathis 0:64ea583d77e2 308
cmathis 0:64ea583d77e2 309 if(levels[buttonPushes-1] != 4){
cmathis 0:64ea583d77e2 310 failed = 1;
cmathis 0:64ea583d77e2 311 }
cmathis 0:64ea583d77e2 312
cmathis 0:64ea583d77e2 313 }
cmathis 0:64ea583d77e2 314
cmathis 0:64ea583d77e2 315 // this function is called when the user fails the game
cmathis 0:64ea583d77e2 316 void failedGame(){
cmathis 0:64ea583d77e2 317
cmathis 0:64ea583d77e2 318 uLCD.cls();
cmathis 0:64ea583d77e2 319 uLCD.color(RED);
cmathis 0:64ea583d77e2 320 uLCD.text_width(2);
cmathis 0:64ea583d77e2 321 uLCD.text_height(2);
cmathis 0:64ea583d77e2 322 uLCD.locate(2, 2);
cmathis 0:64ea583d77e2 323 uLCD.printf("Game");
cmathis 0:64ea583d77e2 324 uLCD.locate(2, 4);
cmathis 0:64ea583d77e2 325 uLCD.printf("Over");
cmathis 0:64ea583d77e2 326
cmathis 0:64ea583d77e2 327
cmathis 2:c92f0e749b94 328 mySpeaker.PlayNote(147.00, 0.60, volume);
cmathis 2:c92f0e749b94 329 mySpeaker.PlayNote(139.00, 0.60, volume);
cmathis 2:c92f0e749b94 330 mySpeaker.PlayNote(131.00, 0.60, volume);
cmathis 2:c92f0e749b94 331 mySpeaker.PlayNote(123.00, 1.60, volume);
cmathis 0:64ea583d77e2 332
cmathis 0:64ea583d77e2 333 }
cmathis 0:64ea583d77e2 334
cmathis 0:64ea583d77e2 335 // this function is called if the user completes all levels
cmathis 0:64ea583d77e2 336 void endGame(){
cmathis 0:64ea583d77e2 337
cmathis 0:64ea583d77e2 338 uLCD.cls();
cmathis 0:64ea583d77e2 339 uLCD.color(GREEN);
cmathis 0:64ea583d77e2 340 uLCD.text_width(2);
cmathis 0:64ea583d77e2 341 uLCD.text_height(2);
cmathis 0:64ea583d77e2 342 uLCD.locate(2, 2);
cmathis 0:64ea583d77e2 343 uLCD.printf("YOU");
cmathis 0:64ea583d77e2 344 uLCD.locate(2, 4);
cmathis 0:64ea583d77e2 345 uLCD.printf("WIN!");
cmathis 0:64ea583d77e2 346
cmathis 0:64ea583d77e2 347 int time = 0.01;
cmathis 0:64ea583d77e2 348
cmathis 2:c92f0e749b94 349 mySpeaker.PlayNote(392.00, 0.33, volume);
cmathis 0:64ea583d77e2 350 wait(time);
cmathis 2:c92f0e749b94 351 mySpeaker.PlayNote(349.23, 0.17, volume);
cmathis 0:64ea583d77e2 352 wait(time);
cmathis 0:64ea583d77e2 353
cmathis 2:c92f0e749b94 354 mySpeaker.PlayNote(311.13, 0.33, volume);
cmathis 0:64ea583d77e2 355 wait(time);
cmathis 2:c92f0e749b94 356 mySpeaker.PlayNote(311.13, 0.17, volume);
cmathis 0:64ea583d77e2 357 wait(time);
cmathis 2:c92f0e749b94 358 mySpeaker.PlayNote(311.13, 0.33, volume);
cmathis 0:64ea583d77e2 359 wait(time);
cmathis 2:c92f0e749b94 360 mySpeaker.PlayNote(349.23, 0.17, volume);
cmathis 0:64ea583d77e2 361 wait(time);
cmathis 0:64ea583d77e2 362
cmathis 2:c92f0e749b94 363 mySpeaker.PlayNote(392.00, 0.33, volume);
cmathis 0:64ea583d77e2 364 wait(time);
cmathis 2:c92f0e749b94 365 mySpeaker.PlayNote(392.00, 0.17, volume);
cmathis 0:64ea583d77e2 366 wait(time);
cmathis 2:c92f0e749b94 367 mySpeaker.PlayNote(392.00, 0.165, volume);
cmathis 0:64ea583d77e2 368 wait(time);
cmathis 2:c92f0e749b94 369 mySpeaker.PlayNote(349.23, 0.165, volume);
cmathis 0:64ea583d77e2 370 wait(time);
cmathis 2:c92f0e749b94 371 mySpeaker.PlayNote(311.13, 0.17, volume);
cmathis 0:64ea583d77e2 372 wait(time);
cmathis 0:64ea583d77e2 373
cmathis 2:c92f0e749b94 374 mySpeaker.PlayNote(349.23, 0.165, volume);
cmathis 0:64ea583d77e2 375 wait(time);
cmathis 2:c92f0e749b94 376 mySpeaker.PlayNote(392.00, 0.165, volume);
cmathis 0:64ea583d77e2 377 wait(time);
cmathis 2:c92f0e749b94 378 mySpeaker.PlayNote(349.23, 0.17, volume);
cmathis 0:64ea583d77e2 379 wait(time);
cmathis 2:c92f0e749b94 380 mySpeaker.PlayNote(311.13, 0.33, volume);
cmathis 0:64ea583d77e2 381 wait(time);
cmathis 2:c92f0e749b94 382 mySpeaker.PlayNote(293.66, 0.17, volume);
cmathis 0:64ea583d77e2 383 wait(time);
cmathis 0:64ea583d77e2 384
cmathis 2:c92f0e749b94 385 mySpeaker.PlayNote(311.13, 0.5, volume);
cmathis 0:64ea583d77e2 386
cmathis 0:64ea583d77e2 387 }