ece 4180 project 2019
Dependencies: mbed wave_player mbed-rtos 4DGL-uLCD-SE SDFileSystem FATFileSystem
main.cpp@3:221fb009c1ac, 2019-04-20 (annotated)
- Committer:
- rhuang77
- Date:
- Sat Apr 20 21:47:57 2019 +0000
- Revision:
- 3:221fb009c1ac
- Parent:
- 2:270569d33ef1
finalizing details
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
rhuang77 | 0:567492543056 | 1 | #include <mbed.h> |
rhuang77 | 0:567492543056 | 2 | #include <mpr121.h> |
rhuang77 | 3:221fb009c1ac | 3 | #include <math.h> |
rhuang77 | 0:567492543056 | 4 | #include "mbed.h" |
rhuang77 | 0:567492543056 | 5 | #include "uLCD_4DGL.h" |
rhuang77 | 0:567492543056 | 6 | #include "SDFileSystem.h" |
rhuang77 | 0:567492543056 | 7 | #include "FATFileSystem.h" |
rhuang77 | 0:567492543056 | 8 | #include "wave_player.h" |
rhuang77 | 0:567492543056 | 9 | #include <stdio.h> |
rhuang77 | 0:567492543056 | 10 | #include "Speaker.h" |
rhuang77 | 1:549f56cb4740 | 11 | #include "rtos.h" |
rhuang77 | 1:549f56cb4740 | 12 | |
rhuang77 | 1:549f56cb4740 | 13 | //Class to control an RGB LED using three PWM pins |
rhuang77 | 1:549f56cb4740 | 14 | class RGBLed |
rhuang77 | 1:549f56cb4740 | 15 | { |
rhuang77 | 1:549f56cb4740 | 16 | public: |
rhuang77 | 1:549f56cb4740 | 17 | RGBLed(PinName redpin, PinName greenpin, PinName bluepin); |
rhuang77 | 1:549f56cb4740 | 18 | void write(float red,float green, float blue); |
rhuang77 | 1:549f56cb4740 | 19 | private: |
rhuang77 | 1:549f56cb4740 | 20 | PwmOut _redpin; |
rhuang77 | 1:549f56cb4740 | 21 | PwmOut _greenpin; |
rhuang77 | 1:549f56cb4740 | 22 | PwmOut _bluepin; |
rhuang77 | 1:549f56cb4740 | 23 | }; |
rhuang77 | 2:270569d33ef1 | 24 | |
rhuang77 | 1:549f56cb4740 | 25 | RGBLed::RGBLed (PinName redpin, PinName greenpin, PinName bluepin) |
rhuang77 | 1:549f56cb4740 | 26 | : _redpin(redpin), _greenpin(greenpin), _bluepin(bluepin) |
rhuang77 | 1:549f56cb4740 | 27 | { |
rhuang77 | 1:549f56cb4740 | 28 | //50Hz PWM clock default a bit too low, go to 2000Hz (less flicker) |
rhuang77 | 1:549f56cb4740 | 29 | _redpin.period(0.0005); |
rhuang77 | 1:549f56cb4740 | 30 | } |
rhuang77 | 2:270569d33ef1 | 31 | |
rhuang77 | 1:549f56cb4740 | 32 | void RGBLed::write(float red,float green, float blue) |
rhuang77 | 1:549f56cb4740 | 33 | { |
rhuang77 | 1:549f56cb4740 | 34 | _redpin = red; |
rhuang77 | 1:549f56cb4740 | 35 | _greenpin = green; |
rhuang77 | 1:549f56cb4740 | 36 | _bluepin = blue; |
rhuang77 | 1:549f56cb4740 | 37 | } |
rhuang77 | 2:270569d33ef1 | 38 | |
rhuang77 | 1:549f56cb4740 | 39 | //Setup RGB led using PWM pins and class |
rhuang77 | 1:549f56cb4740 | 40 | RGBLed myRGBled(p21,p22,p23); //RGB PWM pins |
rhuang77 | 1:549f56cb4740 | 41 | |
rhuang77 | 2:270569d33ef1 | 42 | //Bluetooth |
rhuang77 | 2:270569d33ef1 | 43 | Serial blue(p28,p27); |
rhuang77 | 2:270569d33ef1 | 44 | Serial pc(USBTX, USBRX); |
rhuang77 | 2:270569d33ef1 | 45 | |
rhuang77 | 0:567492543056 | 46 | DigitalOut led1(LED1); |
rhuang77 | 0:567492543056 | 47 | DigitalOut led2(LED2); |
rhuang77 | 0:567492543056 | 48 | DigitalOut led3(LED3); |
rhuang77 | 0:567492543056 | 49 | DigitalOut led4(LED4); |
rhuang77 | 0:567492543056 | 50 | // Create the interrupt receiver object on pin 26 |
rhuang77 | 0:567492543056 | 51 | InterruptIn interrupt(p26); |
rhuang77 | 0:567492543056 | 52 | // Setup the i2c bus on pins 9 and 10 |
rhuang77 | 0:567492543056 | 53 | I2C i2c(p9, p10); |
rhuang77 | 0:567492543056 | 54 | // Setup the Mpr121: |
rhuang77 | 0:567492543056 | 55 | // constructor(i2c object, i2c address of the mpr121) |
rhuang77 | 0:567492543056 | 56 | Mpr121 mpr121(&i2c, Mpr121::ADD_VSS); |
rhuang77 | 0:567492543056 | 57 | |
rhuang77 | 2:270569d33ef1 | 58 | SDFileSystem sd(p5, p6, p7, p8, "sd"); |
rhuang77 | 1:549f56cb4740 | 59 | uLCD_4DGL uLCD(p13,p14,p11); |
rhuang77 | 0:567492543056 | 60 | |
rhuang77 | 2:270569d33ef1 | 61 | AnalogOut DACout(p18); |
rhuang77 | 2:270569d33ef1 | 62 | wave_player waver(&DACout); |
rhuang77 | 2:270569d33ef1 | 63 | FILE *wave_file; |
rhuang77 | 0:567492543056 | 64 | |
rhuang77 | 2:270569d33ef1 | 65 | Mutex stdio_mutex; |
rhuang77 | 2:270569d33ef1 | 66 | |
rhuang77 | 2:270569d33ef1 | 67 | int key_code; |
rhuang77 | 1:549f56cb4740 | 68 | // Key hit/release interrupt routine |
rhuang77 | 2:270569d33ef1 | 69 | void fallInterrupt() |
rhuang77 | 2:270569d33ef1 | 70 | { |
rhuang77 | 2:270569d33ef1 | 71 | key_code=0; |
rhuang77 | 2:270569d33ef1 | 72 | int i=0; |
rhuang77 | 2:270569d33ef1 | 73 | int value=mpr121.read(0x00); |
rhuang77 | 2:270569d33ef1 | 74 | value +=mpr121.read(0x01)<<8; |
rhuang77 | 2:270569d33ef1 | 75 | // LED demo mod |
rhuang77 | 2:270569d33ef1 | 76 | i=0; |
rhuang77 | 2:270569d33ef1 | 77 | // puts key number out to LEDs for demo |
rhuang77 | 2:270569d33ef1 | 78 | for (i=0; i<12; i++) { |
rhuang77 | 2:270569d33ef1 | 79 | if (((value>>i)&0x01)==1) key_code=i+1; |
rhuang77 | 2:270569d33ef1 | 80 | } |
rhuang77 | 2:270569d33ef1 | 81 | led4=key_code & 0x01; |
rhuang77 | 2:270569d33ef1 | 82 | led3=(key_code>>1) & 0x01; |
rhuang77 | 2:270569d33ef1 | 83 | led2=(key_code>>2) & 0x01; |
rhuang77 | 2:270569d33ef1 | 84 | led1=(key_code>>3) & 0x01; |
rhuang77 | 0:567492543056 | 85 | } |
rhuang77 | 1:549f56cb4740 | 86 | |
rhuang77 | 2:270569d33ef1 | 87 | |
rhuang77 | 2:270569d33ef1 | 88 | int songcode = -1; |
rhuang77 | 2:270569d33ef1 | 89 | int isplay = 0; |
rhuang77 | 2:270569d33ef1 | 90 | int islearn = 0; |
rhuang77 | 2:270569d33ef1 | 91 | float volume = 0.25; |
rhuang77 | 3:221fb009c1ac | 92 | float octave = 3; |
rhuang77 | 2:270569d33ef1 | 93 | |
rhuang77 | 2:270569d33ef1 | 94 | |
rhuang77 | 2:270569d33ef1 | 95 | void readblue() |
rhuang77 | 2:270569d33ef1 | 96 | { |
rhuang77 | 2:270569d33ef1 | 97 | while(1) { |
rhuang77 | 2:270569d33ef1 | 98 | |
rhuang77 | 2:270569d33ef1 | 99 | char bnum = 0; |
rhuang77 | 2:270569d33ef1 | 100 | if (blue.readable()) { |
rhuang77 | 2:270569d33ef1 | 101 | if (blue.getc()=='!') { |
rhuang77 | 2:270569d33ef1 | 102 | if (blue.getc() == 'I') { |
rhuang77 | 2:270569d33ef1 | 103 | bnum = blue.getc(); |
rhuang77 | 2:270569d33ef1 | 104 | //button mode |
rhuang77 | 2:270569d33ef1 | 105 | if (bnum == 'B') { |
rhuang77 | 2:270569d33ef1 | 106 | bnum = blue.getc(); |
rhuang77 | 2:270569d33ef1 | 107 | //play song |
rhuang77 | 2:270569d33ef1 | 108 | if (bnum == '0') { |
rhuang77 | 2:270569d33ef1 | 109 | islearn = 0; |
rhuang77 | 2:270569d33ef1 | 110 | isplay = 1; |
rhuang77 | 2:270569d33ef1 | 111 | songcode = blue.getc() - '0'; |
rhuang77 | 2:270569d33ef1 | 112 | } |
rhuang77 | 2:270569d33ef1 | 113 | //learn song |
rhuang77 | 2:270569d33ef1 | 114 | if (bnum == '1') { |
rhuang77 | 2:270569d33ef1 | 115 | islearn = 1; |
rhuang77 | 2:270569d33ef1 | 116 | isplay = 0; |
rhuang77 | 2:270569d33ef1 | 117 | songcode = blue.getc() - '0'; |
rhuang77 | 3:221fb009c1ac | 118 | pc.printf("songcode = %d",songcode); |
rhuang77 | 2:270569d33ef1 | 119 | } |
rhuang77 | 2:270569d33ef1 | 120 | } |
rhuang77 | 2:270569d33ef1 | 121 | //seekbar mode |
rhuang77 | 2:270569d33ef1 | 122 | if (bnum == 'S') { |
rhuang77 | 2:270569d33ef1 | 123 | islearn = 0; |
rhuang77 | 2:270569d33ef1 | 124 | isplay = 0; |
rhuang77 | 2:270569d33ef1 | 125 | bnum = blue.getc(); |
rhuang77 | 2:270569d33ef1 | 126 | //octave change |
rhuang77 | 2:270569d33ef1 | 127 | if (bnum == '0') { |
rhuang77 | 2:270569d33ef1 | 128 | octave = blue.getc() - '0'; |
rhuang77 | 3:221fb009c1ac | 129 | octave = octave - 3; |
rhuang77 | 3:221fb009c1ac | 130 | octave = pow(2, octave); |
rhuang77 | 2:270569d33ef1 | 131 | } |
rhuang77 | 2:270569d33ef1 | 132 | //volume change |
rhuang77 | 2:270569d33ef1 | 133 | if (bnum == '1') { |
rhuang77 | 2:270569d33ef1 | 134 | //get tens digit first |
rhuang77 | 2:270569d33ef1 | 135 | int actualVol = blue.getc() - '0'; |
rhuang77 | 2:270569d33ef1 | 136 | actualVol *= 10; |
rhuang77 | 2:270569d33ef1 | 137 | //then get ones digit |
rhuang77 | 2:270569d33ef1 | 138 | actualVol += blue.getc() - '0'; |
rhuang77 | 2:270569d33ef1 | 139 | volume = (float)actualVol/(float)100; |
rhuang77 | 2:270569d33ef1 | 140 | } |
rhuang77 | 2:270569d33ef1 | 141 | } |
rhuang77 | 2:270569d33ef1 | 142 | } |
rhuang77 | 2:270569d33ef1 | 143 | } |
rhuang77 | 2:270569d33ef1 | 144 | } |
rhuang77 | 2:270569d33ef1 | 145 | Thread::wait(200); |
rhuang77 | 2:270569d33ef1 | 146 | } |
rhuang77 | 1:549f56cb4740 | 147 | } |
rhuang77 | 1:549f56cb4740 | 148 | |
rhuang77 | 2:270569d33ef1 | 149 | int main() |
rhuang77 | 2:270569d33ef1 | 150 | { |
rhuang77 | 2:270569d33ef1 | 151 | |
rhuang77 | 2:270569d33ef1 | 152 | Speaker mySpeaker(p25); |
rhuang77 | 2:270569d33ef1 | 153 | interrupt.fall(&fallInterrupt); |
rhuang77 | 2:270569d33ef1 | 154 | interrupt.mode(PullUp); |
rhuang77 | 2:270569d33ef1 | 155 | uLCD.printf("welcome :)\n"); |
rhuang77 | 2:270569d33ef1 | 156 | wait(1.0); |
rhuang77 | 2:270569d33ef1 | 157 | uLCD.printf("Initializing...\n"); |
rhuang77 | 2:270569d33ef1 | 158 | wait(1.0); |
rhuang77 | 2:270569d33ef1 | 159 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 160 | int i= 0; |
rhuang77 | 3:221fb009c1ac | 161 | int j=0; |
rhuang77 | 3:221fb009c1ac | 162 | Thread thread;; |
rhuang77 | 2:270569d33ef1 | 163 | thread.start(readblue); |
rhuang77 | 2:270569d33ef1 | 164 | |
rhuang77 | 2:270569d33ef1 | 165 | while (1) { |
rhuang77 | 3:221fb009c1ac | 166 | if(islearn == 1) { |
rhuang77 | 3:221fb009c1ac | 167 | pc.printf("songcode in learn = %d",songcode); |
rhuang77 | 3:221fb009c1ac | 168 | if (songcode == 0) { //twinkle |
rhuang77 | 3:221fb009c1ac | 169 | int song0[14] = {1, 1,8,8,10,10,8,6,6,5,5,3,3,1}; |
rhuang77 | 3:221fb009c1ac | 170 | char note0[14] = {'C','C','G','G','A','A','G','F','F','E','E','D','D','C'}; |
rhuang77 | 3:221fb009c1ac | 171 | j = 14; |
rhuang77 | 3:221fb009c1ac | 172 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 173 | //uLCD.printf("starting \nTwinkle Twinkle \nLittle Star"); |
rhuang77 | 3:221fb009c1ac | 174 | //wait(4.0); |
rhuang77 | 3:221fb009c1ac | 175 | while(i <j) { |
rhuang77 | 3:221fb009c1ac | 176 | uLCD.text_width(3); |
rhuang77 | 3:221fb009c1ac | 177 | uLCD.text_height(3); |
rhuang77 | 3:221fb009c1ac | 178 | uLCD.locate(2,2); |
rhuang77 | 2:270569d33ef1 | 179 | |
rhuang77 | 3:221fb009c1ac | 180 | uLCD.printf("%c",note0[i]); |
rhuang77 | 2:270569d33ef1 | 181 | |
rhuang77 | 3:221fb009c1ac | 182 | if(song0[i]==key_code) { |
rhuang77 | 3:221fb009c1ac | 183 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 184 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 185 | i++; |
rhuang77 | 3:221fb009c1ac | 186 | } else if (song0[i] != key_code && key_code != 0) { |
rhuang77 | 3:221fb009c1ac | 187 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 188 | } else if (key_code == 0) { |
rhuang77 | 3:221fb009c1ac | 189 | myRGBled.write(0.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 190 | pc.printf("STAR"); |
rhuang77 | 3:221fb009c1ac | 191 | } |
rhuang77 | 2:270569d33ef1 | 192 | |
rhuang77 | 3:221fb009c1ac | 193 | switch(key_code) { //uses a case statement for each individual touch sensor |
rhuang77 | 2:270569d33ef1 | 194 | |
rhuang77 | 2:270569d33ef1 | 195 | |
rhuang77 | 3:221fb009c1ac | 196 | case 1: |
rhuang77 | 3:221fb009c1ac | 197 | mySpeaker.PlayNote(261.6256, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 198 | break; |
rhuang77 | 3:221fb009c1ac | 199 | case 2: |
rhuang77 | 3:221fb009c1ac | 200 | mySpeaker.PlayNote(277.1826, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 201 | //mySpeaker.PlayNote(261.6256*2, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 202 | break; |
rhuang77 | 3:221fb009c1ac | 203 | case 3: |
rhuang77 | 3:221fb009c1ac | 204 | mySpeaker.PlayNote(293.6648, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 205 | break; |
rhuang77 | 3:221fb009c1ac | 206 | case 4: |
rhuang77 | 3:221fb009c1ac | 207 | mySpeaker.PlayNote(311.1270, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 208 | break; |
rhuang77 | 3:221fb009c1ac | 209 | case 5: |
rhuang77 | 3:221fb009c1ac | 210 | mySpeaker.PlayNote(329.6276, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 211 | break; |
rhuang77 | 3:221fb009c1ac | 212 | case 6: |
rhuang77 | 3:221fb009c1ac | 213 | mySpeaker.PlayNote(349.2282, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 214 | break; |
rhuang77 | 3:221fb009c1ac | 215 | case 7: |
rhuang77 | 3:221fb009c1ac | 216 | mySpeaker.PlayNote(369.9944, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 217 | break; |
rhuang77 | 3:221fb009c1ac | 218 | case 8: |
rhuang77 | 3:221fb009c1ac | 219 | mySpeaker.PlayNote(391.9954, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 220 | break; |
rhuang77 | 3:221fb009c1ac | 221 | case 9: |
rhuang77 | 3:221fb009c1ac | 222 | mySpeaker.PlayNote(415.3047, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 223 | break; |
rhuang77 | 3:221fb009c1ac | 224 | case 10: |
rhuang77 | 3:221fb009c1ac | 225 | mySpeaker.PlayNote(440.0, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 226 | break; |
rhuang77 | 3:221fb009c1ac | 227 | case 11: |
rhuang77 | 3:221fb009c1ac | 228 | mySpeaker.PlayNote(466.1638, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 229 | break; |
rhuang77 | 3:221fb009c1ac | 230 | case 12: |
rhuang77 | 3:221fb009c1ac | 231 | mySpeaker.PlayNote(493.8833, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 232 | break; |
rhuang77 | 3:221fb009c1ac | 233 | } |
rhuang77 | 3:221fb009c1ac | 234 | } |
rhuang77 | 3:221fb009c1ac | 235 | i = 0; |
rhuang77 | 3:221fb009c1ac | 236 | uLCD.printf("Congratulations! \nYou learned \nTwinkle Twinkle \nLittle Star"); |
rhuang77 | 3:221fb009c1ac | 237 | } else if (songcode == 1) { //mary had a little lamb |
rhuang77 | 3:221fb009c1ac | 238 | int song1[25] = {5, 3, 1, 3, 5, 5, 5, 3, 3, 3, 5, 8, 8, 5, 3, 1, 3, 5, 5, 5, 5, 3, 5, 3, 1}; |
rhuang77 | 3:221fb009c1ac | 239 | char note1[25] = {'E', 'D', 'C', 'D', 'E','E','E', 'D','D','D','E', 'G','G','E', 'D', 'C', 'D', 'E','E','E','E','D','E','D','C'}; |
rhuang77 | 3:221fb009c1ac | 240 | j = 25; |
rhuang77 | 3:221fb009c1ac | 241 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 242 | //uLCD.printf("starting \nTwinkle Twinkle \nLittle Star"); |
rhuang77 | 3:221fb009c1ac | 243 | //wait(4.0); |
rhuang77 | 3:221fb009c1ac | 244 | while(i <j) { |
rhuang77 | 3:221fb009c1ac | 245 | uLCD.text_width(3); |
rhuang77 | 3:221fb009c1ac | 246 | uLCD.text_height(3); |
rhuang77 | 3:221fb009c1ac | 247 | uLCD.locate(2,2); |
rhuang77 | 2:270569d33ef1 | 248 | |
rhuang77 | 3:221fb009c1ac | 249 | uLCD.printf("%c",note1[i]); |
rhuang77 | 3:221fb009c1ac | 250 | |
rhuang77 | 3:221fb009c1ac | 251 | if(song1[i]==key_code) { |
rhuang77 | 3:221fb009c1ac | 252 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 253 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 254 | i++; |
rhuang77 | 3:221fb009c1ac | 255 | } else if (song1[i] != key_code && key_code != 0) { |
rhuang77 | 3:221fb009c1ac | 256 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 257 | } else if (key_code == 0) { |
rhuang77 | 3:221fb009c1ac | 258 | myRGBled.write(0.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 259 | pc.printf("MARY"); |
rhuang77 | 3:221fb009c1ac | 260 | } |
rhuang77 | 3:221fb009c1ac | 261 | |
rhuang77 | 3:221fb009c1ac | 262 | switch(key_code) { //uses a case statement for each individual touch sensor |
rhuang77 | 2:270569d33ef1 | 263 | |
rhuang77 | 2:270569d33ef1 | 264 | |
rhuang77 | 3:221fb009c1ac | 265 | case 1: |
rhuang77 | 3:221fb009c1ac | 266 | mySpeaker.PlayNote(261.6256, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 267 | break; |
rhuang77 | 3:221fb009c1ac | 268 | case 2: |
rhuang77 | 3:221fb009c1ac | 269 | mySpeaker.PlayNote(277.1826, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 270 | //mySpeaker.PlayNote(261.6256*2, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 271 | break; |
rhuang77 | 3:221fb009c1ac | 272 | case 3: |
rhuang77 | 3:221fb009c1ac | 273 | mySpeaker.PlayNote(293.6648, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 274 | break; |
rhuang77 | 3:221fb009c1ac | 275 | case 4: |
rhuang77 | 3:221fb009c1ac | 276 | mySpeaker.PlayNote(311.1270, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 277 | break; |
rhuang77 | 3:221fb009c1ac | 278 | case 5: |
rhuang77 | 3:221fb009c1ac | 279 | mySpeaker.PlayNote(329.6276, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 280 | break; |
rhuang77 | 3:221fb009c1ac | 281 | case 6: |
rhuang77 | 3:221fb009c1ac | 282 | mySpeaker.PlayNote(349.2282, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 283 | break; |
rhuang77 | 3:221fb009c1ac | 284 | case 7: |
rhuang77 | 3:221fb009c1ac | 285 | mySpeaker.PlayNote(369.9944, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 286 | break; |
rhuang77 | 3:221fb009c1ac | 287 | case 8: |
rhuang77 | 3:221fb009c1ac | 288 | mySpeaker.PlayNote(391.9954, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 289 | break; |
rhuang77 | 3:221fb009c1ac | 290 | case 9: |
rhuang77 | 3:221fb009c1ac | 291 | mySpeaker.PlayNote(415.3047, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 292 | break; |
rhuang77 | 3:221fb009c1ac | 293 | case 10: |
rhuang77 | 3:221fb009c1ac | 294 | mySpeaker.PlayNote(440.0, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 295 | break; |
rhuang77 | 3:221fb009c1ac | 296 | case 11: |
rhuang77 | 3:221fb009c1ac | 297 | mySpeaker.PlayNote(466.1638, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 298 | break; |
rhuang77 | 3:221fb009c1ac | 299 | case 12: |
rhuang77 | 3:221fb009c1ac | 300 | mySpeaker.PlayNote(493.8833, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 301 | break; |
rhuang77 | 3:221fb009c1ac | 302 | } |
rhuang77 | 2:270569d33ef1 | 303 | } |
rhuang77 | 3:221fb009c1ac | 304 | i = 0; |
rhuang77 | 3:221fb009c1ac | 305 | uLCD.printf("Congratulations! \nYou learned \nMary Had a \nLittle Lamb"); |
rhuang77 | 3:221fb009c1ac | 306 | } else if (songcode == 2) { //hot cross buns |
rhuang77 | 3:221fb009c1ac | 307 | int song2[17] = {5, 3, 1, 5, 3, 1, 1, 1, 1, 1, 3, 3, 3, 3, 5, 3, 1}; |
rhuang77 | 3:221fb009c1ac | 308 | char note2[17] = {'E','D','C','E','D','C', 'C','C','C','C','D','D','D','D','E','D','C'}; |
rhuang77 | 3:221fb009c1ac | 309 | j = 17; |
rhuang77 | 3:221fb009c1ac | 310 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 311 | //uLCD.printf("starting \nTwinkle Twinkle \nLittle Star"); |
rhuang77 | 3:221fb009c1ac | 312 | //wait(4.0); |
rhuang77 | 3:221fb009c1ac | 313 | while(i <j) { |
rhuang77 | 3:221fb009c1ac | 314 | uLCD.text_width(3); |
rhuang77 | 3:221fb009c1ac | 315 | uLCD.text_height(3); |
rhuang77 | 3:221fb009c1ac | 316 | uLCD.locate(2,2); |
rhuang77 | 3:221fb009c1ac | 317 | |
rhuang77 | 3:221fb009c1ac | 318 | uLCD.printf("%c",note2[i]); |
rhuang77 | 3:221fb009c1ac | 319 | |
rhuang77 | 3:221fb009c1ac | 320 | if(song2[i]==key_code) { |
rhuang77 | 3:221fb009c1ac | 321 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 322 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 323 | i++; |
rhuang77 | 3:221fb009c1ac | 324 | } else if (song2[i] != key_code && key_code != 0) { |
rhuang77 | 3:221fb009c1ac | 325 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 326 | } else if (key_code == 0) { |
rhuang77 | 3:221fb009c1ac | 327 | myRGBled.write(0.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 328 | pc.printf("BUNS"); |
rhuang77 | 3:221fb009c1ac | 329 | } |
rhuang77 | 3:221fb009c1ac | 330 | |
rhuang77 | 3:221fb009c1ac | 331 | switch(key_code) { //uses a case statement for each individual touch sensor |
rhuang77 | 2:270569d33ef1 | 332 | |
rhuang77 | 2:270569d33ef1 | 333 | |
rhuang77 | 3:221fb009c1ac | 334 | case 1: |
rhuang77 | 3:221fb009c1ac | 335 | mySpeaker.PlayNote(261.6256, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 336 | break; |
rhuang77 | 3:221fb009c1ac | 337 | case 2: |
rhuang77 | 3:221fb009c1ac | 338 | mySpeaker.PlayNote(277.1826, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 339 | //mySpeaker.PlayNote(261.6256*2, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 340 | break; |
rhuang77 | 3:221fb009c1ac | 341 | case 3: |
rhuang77 | 3:221fb009c1ac | 342 | mySpeaker.PlayNote(293.6648, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 343 | break; |
rhuang77 | 3:221fb009c1ac | 344 | case 4: |
rhuang77 | 3:221fb009c1ac | 345 | mySpeaker.PlayNote(311.1270, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 346 | break; |
rhuang77 | 3:221fb009c1ac | 347 | case 5: |
rhuang77 | 3:221fb009c1ac | 348 | mySpeaker.PlayNote(329.6276, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 349 | break; |
rhuang77 | 3:221fb009c1ac | 350 | case 6: |
rhuang77 | 3:221fb009c1ac | 351 | mySpeaker.PlayNote(349.2282, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 352 | break; |
rhuang77 | 3:221fb009c1ac | 353 | case 7: |
rhuang77 | 3:221fb009c1ac | 354 | mySpeaker.PlayNote(369.9944, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 355 | break; |
rhuang77 | 3:221fb009c1ac | 356 | case 8: |
rhuang77 | 3:221fb009c1ac | 357 | mySpeaker.PlayNote(391.9954, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 358 | break; |
rhuang77 | 3:221fb009c1ac | 359 | case 9: |
rhuang77 | 3:221fb009c1ac | 360 | mySpeaker.PlayNote(415.3047, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 361 | break; |
rhuang77 | 3:221fb009c1ac | 362 | case 10: |
rhuang77 | 3:221fb009c1ac | 363 | mySpeaker.PlayNote(440.0, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 364 | break; |
rhuang77 | 3:221fb009c1ac | 365 | case 11: |
rhuang77 | 3:221fb009c1ac | 366 | mySpeaker.PlayNote(466.1638, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 367 | break; |
rhuang77 | 3:221fb009c1ac | 368 | case 12: |
rhuang77 | 3:221fb009c1ac | 369 | mySpeaker.PlayNote(493.8833, 0.5, volume); |
rhuang77 | 3:221fb009c1ac | 370 | break; |
rhuang77 | 3:221fb009c1ac | 371 | } |
rhuang77 | 3:221fb009c1ac | 372 | } |
rhuang77 | 3:221fb009c1ac | 373 | i = 0; |
rhuang77 | 3:221fb009c1ac | 374 | uLCD.printf("Congratulations! \nYou learned \nHot Cross \nBuns"); |
rhuang77 | 2:270569d33ef1 | 375 | } |
rhuang77 | 3:221fb009c1ac | 376 | //wait(4.0); |
rhuang77 | 3:221fb009c1ac | 377 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 378 | islearn=0; |
rhuang77 | 3:221fb009c1ac | 379 | //Thread::wait(200); |
rhuang77 | 3:221fb009c1ac | 380 | } else if(isplay == 1) { |
rhuang77 | 2:270569d33ef1 | 381 | uLCD.cls(); |
rhuang77 | 3:221fb009c1ac | 382 | // uLCD.printf("Playing song"); |
rhuang77 | 3:221fb009c1ac | 383 | // wait(2.0); |
rhuang77 | 3:221fb009c1ac | 384 | if (songcode == 0) { |
rhuang77 | 3:221fb009c1ac | 385 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 386 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 387 | mySpeaker.PlayNote(391.9954, 0.5, volume); //G |
rhuang77 | 3:221fb009c1ac | 388 | mySpeaker.PlayNote(391.9954, 0.5, volume); //G |
rhuang77 | 3:221fb009c1ac | 389 | mySpeaker.PlayNote(440.0, 0.5, volume); //A |
rhuang77 | 3:221fb009c1ac | 390 | mySpeaker.PlayNote(440.0, 0.5, volume); //A |
rhuang77 | 3:221fb009c1ac | 391 | mySpeaker.PlayNote(391.9954, 1.0, volume); //G |
rhuang77 | 3:221fb009c1ac | 392 | mySpeaker.PlayNote(349.2282, 0.5, volume); //F |
rhuang77 | 3:221fb009c1ac | 393 | mySpeaker.PlayNote(349.2282, 0.5, volume); //F |
rhuang77 | 3:221fb009c1ac | 394 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 395 | mySpeaker.PlayNote(329.6276, 0.5, volume); //E |
rhuang77 | 3:221fb009c1ac | 396 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 397 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 398 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 399 | } else if (songcode == 1) { |
rhuang77 | 3:221fb009c1ac | 400 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 401 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 402 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 403 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 404 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 405 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 406 | mySpeaker.PlayNote(329.6276, 1.0, volume); // E |
rhuang77 | 3:221fb009c1ac | 407 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 408 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 409 | mySpeaker.PlayNote(293.6648, 1.0, volume); //D |
rhuang77 | 3:221fb009c1ac | 410 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 411 | mySpeaker.PlayNote(391.9954, 0.5, volume); //G |
rhuang77 | 3:221fb009c1ac | 412 | mySpeaker.PlayNote(391.9954, 1.0, volume); //G |
rhuang77 | 3:221fb009c1ac | 413 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 414 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 415 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 416 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 417 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 418 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 419 | mySpeaker.PlayNote(329.6276, 1.0, volume); // E |
rhuang77 | 3:221fb009c1ac | 420 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 421 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 422 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 423 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 424 | mySpeaker.PlayNote(261.6256, 1.0, volume); //C |
rhuang77 | 3:221fb009c1ac | 425 | } else if (songcode == 2) { |
rhuang77 | 3:221fb009c1ac | 426 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 427 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 428 | mySpeaker.PlayNote(261.6256, 1.0, volume); //C |
rhuang77 | 3:221fb009c1ac | 429 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 430 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 431 | mySpeaker.PlayNote(261.6256, 1.0, volume); //C |
rhuang77 | 3:221fb009c1ac | 432 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 433 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 434 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 435 | mySpeaker.PlayNote(261.6256, 0.5, volume); //C |
rhuang77 | 3:221fb009c1ac | 436 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 437 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 438 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 439 | mySpeaker.PlayNote(329.6276, 0.5, volume); // E |
rhuang77 | 3:221fb009c1ac | 440 | mySpeaker.PlayNote(293.6648, 0.5, volume); //D |
rhuang77 | 3:221fb009c1ac | 441 | mySpeaker.PlayNote(261.6256, 1.0, volume); //C |
rhuang77 | 3:221fb009c1ac | 442 | } |
rhuang77 | 3:221fb009c1ac | 443 | isplay = 0; |
rhuang77 | 1:549f56cb4740 | 444 | } |
rhuang77 | 2:270569d33ef1 | 445 | |
rhuang77 | 2:270569d33ef1 | 446 | else { |
rhuang77 | 2:270569d33ef1 | 447 | |
rhuang77 | 2:270569d33ef1 | 448 | |
rhuang77 | 2:270569d33ef1 | 449 | switch(key_code) { //uses a case statement for each individual touch sensor |
rhuang77 | 2:270569d33ef1 | 450 | case 1: |
rhuang77 | 2:270569d33ef1 | 451 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 452 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 453 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 454 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 455 | uLCD.printf("C"); |
rhuang77 | 2:270569d33ef1 | 456 | //printf("%d", key_code); |
rhuang77 | 2:270569d33ef1 | 457 | |
rhuang77 | 2:270569d33ef1 | 458 | myRGBled.write(0.0,0.0,1.0 ); |
rhuang77 | 3:221fb009c1ac | 459 | mySpeaker.PlayNote(261.6256 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 460 | break; |
rhuang77 | 2:270569d33ef1 | 461 | case 2: |
rhuang77 | 2:270569d33ef1 | 462 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 463 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 464 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 465 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 466 | uLCD.printf("CS"); |
rhuang77 | 3:221fb009c1ac | 467 | myRGBled.write(0.0,0.0,1.0 ); |
rhuang77 | 3:221fb009c1ac | 468 | |
rhuang77 | 3:221fb009c1ac | 469 | mySpeaker.PlayNote(277.1826 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 470 | break; |
rhuang77 | 2:270569d33ef1 | 471 | case 3: |
rhuang77 | 2:270569d33ef1 | 472 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 473 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 474 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 475 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 476 | uLCD.printf("D"); |
rhuang77 | 3:221fb009c1ac | 477 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 478 | |
rhuang77 | 3:221fb009c1ac | 479 | mySpeaker.PlayNote(293.6648 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 480 | break; |
rhuang77 | 2:270569d33ef1 | 481 | case 4: |
rhuang77 | 2:270569d33ef1 | 482 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 483 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 484 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 485 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 486 | uLCD.printf("DS"); |
rhuang77 | 3:221fb009c1ac | 487 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 488 | mySpeaker.PlayNote(311.1270 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 489 | break; |
rhuang77 | 2:270569d33ef1 | 490 | case 5: |
rhuang77 | 2:270569d33ef1 | 491 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 492 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 493 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 494 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 495 | uLCD.printf("E"); |
rhuang77 | 3:221fb009c1ac | 496 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 497 | mySpeaker.PlayNote(329.6276 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 498 | break; |
rhuang77 | 2:270569d33ef1 | 499 | case 6: |
rhuang77 | 2:270569d33ef1 | 500 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 501 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 502 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 503 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 504 | uLCD.printf("F"); |
rhuang77 | 3:221fb009c1ac | 505 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 506 | mySpeaker.PlayNote(349.2282 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 507 | break; |
rhuang77 | 2:270569d33ef1 | 508 | case 7: |
rhuang77 | 2:270569d33ef1 | 509 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 510 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 511 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 512 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 513 | uLCD.printf("FS"); |
rhuang77 | 3:221fb009c1ac | 514 | myRGBled.write(0.0,0.0,1.0 ); |
rhuang77 | 3:221fb009c1ac | 515 | mySpeaker.PlayNote(369.9944 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 516 | break; |
rhuang77 | 2:270569d33ef1 | 517 | case 8: |
rhuang77 | 2:270569d33ef1 | 518 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 519 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 520 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 521 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 522 | uLCD.printf("G"); |
rhuang77 | 3:221fb009c1ac | 523 | myRGBled.write(0.0,0.0,1.0 ); |
rhuang77 | 3:221fb009c1ac | 524 | mySpeaker.PlayNote(391.9954 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 525 | break; |
rhuang77 | 2:270569d33ef1 | 526 | case 9: |
rhuang77 | 2:270569d33ef1 | 527 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 528 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 529 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 530 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 531 | uLCD.printf("GS"); |
rhuang77 | 3:221fb009c1ac | 532 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 533 | mySpeaker.PlayNote(415.3047 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 534 | break; |
rhuang77 | 2:270569d33ef1 | 535 | case 10: |
rhuang77 | 2:270569d33ef1 | 536 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 537 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 538 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 539 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 540 | uLCD.printf("A"); |
rhuang77 | 3:221fb009c1ac | 541 | myRGBled.write(1.0,0.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 542 | mySpeaker.PlayNote(440.0 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 543 | break; |
rhuang77 | 2:270569d33ef1 | 544 | case 11: |
rhuang77 | 2:270569d33ef1 | 545 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 546 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 547 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 548 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 549 | uLCD.printf("AS"); |
rhuang77 | 3:221fb009c1ac | 550 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 551 | mySpeaker.PlayNote(466.1638 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 552 | break; |
rhuang77 | 2:270569d33ef1 | 553 | case 12: |
rhuang77 | 2:270569d33ef1 | 554 | uLCD.cls(); |
rhuang77 | 2:270569d33ef1 | 555 | uLCD.locate(6,6); |
rhuang77 | 2:270569d33ef1 | 556 | uLCD.text_width(5); |
rhuang77 | 2:270569d33ef1 | 557 | uLCD.text_height(5); |
rhuang77 | 2:270569d33ef1 | 558 | uLCD.printf("B"); |
rhuang77 | 3:221fb009c1ac | 559 | myRGBled.write(0.0,1.0,0.0 ); |
rhuang77 | 3:221fb009c1ac | 560 | mySpeaker.PlayNote(493.8833 * octave, 0.5, volume); |
rhuang77 | 2:270569d33ef1 | 561 | break; |
rhuang77 | 2:270569d33ef1 | 562 | } |
rhuang77 | 2:270569d33ef1 | 563 | } |
rhuang77 | 2:270569d33ef1 | 564 | Thread::wait(200); |
rhuang77 | 1:549f56cb4740 | 565 | } |
rhuang77 | 1:549f56cb4740 | 566 | } |
rhuang77 | 0:567492543056 | 567 | |
rhuang77 | 0:567492543056 | 568 | |
rhuang77 | 0:567492543056 | 569 |