For Pet_Finder

Dependencies:   Adafruit_GFX Adafruit_ST7735 Adafruit_TFT_Shieldv1_graphicstest SDFileSystem mbed

Fork of Adafruit_TFT_Shieldv1_graphicstest by justin kim

Committer:
GabrielGoichman
Date:
Mon May 22 14:03:48 2017 +0000
Revision:
4:41b8a8713b49
Parent:
2:e64c231f0abb
11

Who changed what in which revision?

UserRevisionLine numberNew contents of line
justinkim 0:b0981712db9b 1 #include "mbed.h"
justinkim 0:b0981712db9b 2 #include "Adafruit_ST7735.h"
justinkim 0:b0981712db9b 3
GabrielGoichman 4:41b8a8713b49 4 // NB: ALL NOTES DEFINED WITH STANDARD ENGLISH NAMES, EXCEPT FROM "A"
GabrielGoichman 4:41b8a8713b49 5 //THAT IS CALLED WITH THE ITALIAN NAME "LA" BECAUSE A0,A1...ARE THE ANALOG PINS ON ARDUINO.
GabrielGoichman 4:41b8a8713b49 6 // (Ab IS CALLED Ab AND NOT LAb)
GabrielGoichman 4:41b8a8713b49 7 #define C0 16.35
GabrielGoichman 4:41b8a8713b49 8 #define Db0 17.32
GabrielGoichman 4:41b8a8713b49 9 #define D0 18.35
GabrielGoichman 4:41b8a8713b49 10 #define Eb0 19.45
GabrielGoichman 4:41b8a8713b49 11 #define E0 20.60
GabrielGoichman 4:41b8a8713b49 12 #define F0 21.83
GabrielGoichman 4:41b8a8713b49 13 #define Gb0 23.12
GabrielGoichman 4:41b8a8713b49 14 #define G0 24.50
GabrielGoichman 4:41b8a8713b49 15 #define Ab0 25.96
GabrielGoichman 4:41b8a8713b49 16 #define LA0 27.50
GabrielGoichman 4:41b8a8713b49 17 #define Bb0 29.14
GabrielGoichman 4:41b8a8713b49 18 #define B0 30.87
GabrielGoichman 4:41b8a8713b49 19 #define C1 32.70
GabrielGoichman 4:41b8a8713b49 20 #define Db1 34.65
GabrielGoichman 4:41b8a8713b49 21 #define D1 36.71
GabrielGoichman 4:41b8a8713b49 22 #define Eb1 38.89
GabrielGoichman 4:41b8a8713b49 23 #define E1 41.20
GabrielGoichman 4:41b8a8713b49 24 #define F1 43.65
GabrielGoichman 4:41b8a8713b49 25 #define Gb1 46.25
GabrielGoichman 4:41b8a8713b49 26 #define G1 49.00
GabrielGoichman 4:41b8a8713b49 27 #define Ab1 51.91
GabrielGoichman 4:41b8a8713b49 28 #define LA1 55.00
GabrielGoichman 4:41b8a8713b49 29 #define Bb1 58.27
GabrielGoichman 4:41b8a8713b49 30 #define B1 61.74
GabrielGoichman 4:41b8a8713b49 31 #define C2 65.41
GabrielGoichman 4:41b8a8713b49 32 #define Db2 69.30
GabrielGoichman 4:41b8a8713b49 33 #define D2 73.42
GabrielGoichman 4:41b8a8713b49 34 #define Eb2 77.78
GabrielGoichman 4:41b8a8713b49 35 #define E2 82.41
GabrielGoichman 4:41b8a8713b49 36 #define F2 87.31
GabrielGoichman 4:41b8a8713b49 37 #define Gb2 92.50
GabrielGoichman 4:41b8a8713b49 38 #define G2 98.00
GabrielGoichman 4:41b8a8713b49 39 #define Ab2 103.83
GabrielGoichman 4:41b8a8713b49 40 #define LA2 110.00
GabrielGoichman 4:41b8a8713b49 41 #define Bb2 116.54
GabrielGoichman 4:41b8a8713b49 42 #define B2 123.47
GabrielGoichman 4:41b8a8713b49 43 #define C3 130.81
GabrielGoichman 4:41b8a8713b49 44 #define Db3 138.59
GabrielGoichman 4:41b8a8713b49 45 #define D3 146.83
GabrielGoichman 4:41b8a8713b49 46 #define Eb3 155.56
GabrielGoichman 4:41b8a8713b49 47 #define E3 164.81
GabrielGoichman 4:41b8a8713b49 48 #define F3 174.61
GabrielGoichman 4:41b8a8713b49 49 #define Gb3 185.00
GabrielGoichman 4:41b8a8713b49 50 #define G3 196.00
GabrielGoichman 4:41b8a8713b49 51 #define Ab3 207.65
GabrielGoichman 4:41b8a8713b49 52 #define LA3 220.00
GabrielGoichman 4:41b8a8713b49 53 #define Bb3 233.08
GabrielGoichman 4:41b8a8713b49 54 #define B3 246.94
GabrielGoichman 4:41b8a8713b49 55 #define C4 261.63
GabrielGoichman 4:41b8a8713b49 56 #define Db4 277.18
GabrielGoichman 4:41b8a8713b49 57 #define D4 293.66
GabrielGoichman 4:41b8a8713b49 58 #define Eb4 311.13
GabrielGoichman 4:41b8a8713b49 59 #define E4 329.63
GabrielGoichman 4:41b8a8713b49 60 #define F4 349.23
GabrielGoichman 4:41b8a8713b49 61 #define Gb4 369.99
GabrielGoichman 4:41b8a8713b49 62 #define G4 392.00
GabrielGoichman 4:41b8a8713b49 63 #define Ab4 415.30
GabrielGoichman 4:41b8a8713b49 64 #define LA4 440.00
GabrielGoichman 4:41b8a8713b49 65 #define Bb4 466.16
GabrielGoichman 4:41b8a8713b49 66 #define B4 493.88
GabrielGoichman 4:41b8a8713b49 67 #define C5 523.25
GabrielGoichman 4:41b8a8713b49 68 #define Db5 554.37
GabrielGoichman 4:41b8a8713b49 69 #define D5 587.33
GabrielGoichman 4:41b8a8713b49 70 #define Eb5 622.25
GabrielGoichman 4:41b8a8713b49 71 #define E5 659.26
GabrielGoichman 4:41b8a8713b49 72 #define F5 698.46
GabrielGoichman 4:41b8a8713b49 73 #define Gb5 739.99
GabrielGoichman 4:41b8a8713b49 74 #define G5 783.99
GabrielGoichman 4:41b8a8713b49 75 #define Ab5 830.61
GabrielGoichman 4:41b8a8713b49 76 #define LA5 880.00
GabrielGoichman 4:41b8a8713b49 77 #define Bb5 932.33
GabrielGoichman 4:41b8a8713b49 78 #define B5 987.77
GabrielGoichman 4:41b8a8713b49 79 #define C6 1046.50
GabrielGoichman 4:41b8a8713b49 80 #define Db6 1108.73
GabrielGoichman 4:41b8a8713b49 81 #define D6 1174.66
GabrielGoichman 4:41b8a8713b49 82 #define Eb6 1244.51
GabrielGoichman 4:41b8a8713b49 83 #define E6 1318.51
GabrielGoichman 4:41b8a8713b49 84 #define F6 1396.91
GabrielGoichman 4:41b8a8713b49 85 #define Gb6 1479.98
GabrielGoichman 4:41b8a8713b49 86 #define G6 1567.98
GabrielGoichman 4:41b8a8713b49 87 #define Ab6 1661.22
GabrielGoichman 4:41b8a8713b49 88 #define LA6 1760.00
GabrielGoichman 4:41b8a8713b49 89 #define Bb6 1864.66
GabrielGoichman 4:41b8a8713b49 90 #define B6 1975.53
GabrielGoichman 4:41b8a8713b49 91 #define C7 2093.00
GabrielGoichman 4:41b8a8713b49 92 #define Db7 2217.46
GabrielGoichman 4:41b8a8713b49 93 #define D7 2349.32
GabrielGoichman 4:41b8a8713b49 94 #define Eb7 2489.02
GabrielGoichman 4:41b8a8713b49 95 #define E7 2637.02
GabrielGoichman 4:41b8a8713b49 96 #define F7 2793.83
GabrielGoichman 4:41b8a8713b49 97 #define Gb7 2959.96
GabrielGoichman 4:41b8a8713b49 98 #define G7 3135.96
GabrielGoichman 4:41b8a8713b49 99 #define Ab7 3322.44
GabrielGoichman 4:41b8a8713b49 100 #define LA7 3520.01
GabrielGoichman 4:41b8a8713b49 101 #define Bb7 3729.31
GabrielGoichman 4:41b8a8713b49 102 #define B7 3951.07
GabrielGoichman 4:41b8a8713b49 103 #define C8 4186.01
GabrielGoichman 4:41b8a8713b49 104 #define Db8 4434.92
GabrielGoichman 4:41b8a8713b49 105 #define D8 4698.64
GabrielGoichman 4:41b8a8713b49 106 #define Eb8 4978.03
GabrielGoichman 4:41b8a8713b49 107 // DURATION OF THE NOTES
GabrielGoichman 4:41b8a8713b49 108 #define BPM 120 // you can change this value changing all the others
GabrielGoichman 4:41b8a8713b49 109 #define H 2*Q //half 2/4
GabrielGoichman 4:41b8a8713b49 110 #define Q 60000/BPM //quarter 1/4
GabrielGoichman 4:41b8a8713b49 111 #define E Q/2 //eighth 1/8
GabrielGoichman 4:41b8a8713b49 112 #define S Q/4 // sixteenth 1/16
GabrielGoichman 4:41b8a8713b49 113 #define W 4*Q // whole 4/4
justinkim 0:b0981712db9b 114
GabrielGoichman 4:41b8a8713b49 115
GabrielGoichman 4:41b8a8713b49 116 //Adafruit_ST7735 tft(D11, D12, D13, D10, D8, D9); // MOSI, MISO, SCLK, SSEL, TFT_DC, TFT_RST
GabrielGoichman 4:41b8a8713b49 117 PwmOut Oito(PB_10);
justinkim 0:b0981712db9b 118
GabrielGoichman 4:41b8a8713b49 119 //void testlines(uint16_t color);
GabrielGoichman 4:41b8a8713b49 120 //void testfastlines(uint16_t color1, uint16_t color2);
GabrielGoichman 4:41b8a8713b49 121 //void IniciandoMaquina(void);
GabrielGoichman 4:41b8a8713b49 122 //void Alerta(void);
GabrielGoichman 4:41b8a8713b49 123 //void MenuPrincipal(void);
GabrielGoichman 4:41b8a8713b49 124 //void Aguarde(void);
GabrielGoichman 4:41b8a8713b49 125 //void Executando(void);
GabrielGoichman 4:41b8a8713b49 126 void loop(void);
justinkim 0:b0981712db9b 127 int main(void)
justinkim 0:b0981712db9b 128 {
GabrielGoichman 2:e64c231f0abb 129 // Use this initializer if you're using a 1.8" TFT
GabrielGoichman 4:41b8a8713b49 130 // tft.initR(INITR_BLACKTAB); // initialize a ST7735S chip, black tab
justinkim 0:b0981712db9b 131
GabrielGoichman 2:e64c231f0abb 132 //iniciando máquina
GabrielGoichman 4:41b8a8713b49 133 //IniciandoMaquina();
GabrielGoichman 4:41b8a8713b49 134 //wait_ms(5000);
GabrielGoichman 4:41b8a8713b49 135 //Alerta();
GabrielGoichman 4:41b8a8713b49 136 //wait_ms(5000);
GabrielGoichman 4:41b8a8713b49 137 //MenuPrincipal();
GabrielGoichman 4:41b8a8713b49 138 //wait_ms(5000);
GabrielGoichman 4:41b8a8713b49 139 //Aguarde();
GabrielGoichman 4:41b8a8713b49 140 //wait_ms(5000);
GabrielGoichman 4:41b8a8713b49 141 //Executando();
GabrielGoichman 4:41b8a8713b49 142 //wait_ms(5000);
GabrielGoichman 4:41b8a8713b49 143 //InicioProcessoReferenciamento();
GabrielGoichman 4:41b8a8713b49 144 loop();
GabrielGoichman 2:e64c231f0abb 145 wait_ms(5000);
justinkim 0:b0981712db9b 146 }
justinkim 0:b0981712db9b 147
GabrielGoichman 2:e64c231f0abb 148 // ----------------------------------------------------------------------------------------------------------------
GabrielGoichman 2:e64c231f0abb 149
GabrielGoichman 4:41b8a8713b49 150 /*
GabrielGoichman 2:e64c231f0abb 151
GabrielGoichman 2:e64c231f0abb 152 void testlines(uint16_t color)
GabrielGoichman 2:e64c231f0abb 153 {
GabrielGoichman 2:e64c231f0abb 154 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 155 for (int16_t x=0; x < tft.width(); x+=6) {
GabrielGoichman 2:e64c231f0abb 156 tft.drawLine(0, 0, x, tft.height()-1, color);
GabrielGoichman 2:e64c231f0abb 157 }
GabrielGoichman 2:e64c231f0abb 158 for (int16_t y=0; y < tft.height(); y+=6) {
GabrielGoichman 2:e64c231f0abb 159 tft.drawLine(0, 0, tft.width()-1, y, color);
GabrielGoichman 2:e64c231f0abb 160 }
justinkim 0:b0981712db9b 161
GabrielGoichman 2:e64c231f0abb 162 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 163 for (int16_t x=0; x < tft.width(); x+=6) {
GabrielGoichman 2:e64c231f0abb 164 tft.drawLine(tft.width()-1, 0, x, tft.height()-1, color);
GabrielGoichman 2:e64c231f0abb 165 }
GabrielGoichman 2:e64c231f0abb 166 for (int16_t y=0; y < tft.height(); y+=6) {
GabrielGoichman 2:e64c231f0abb 167 tft.drawLine(tft.width()-1, 0, 0, y, color);
GabrielGoichman 2:e64c231f0abb 168 }
justinkim 0:b0981712db9b 169
GabrielGoichman 2:e64c231f0abb 170 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 171 for (int16_t x=0; x < tft.width(); x+=6) {
GabrielGoichman 2:e64c231f0abb 172 tft.drawLine(0, tft.height()-1, x, 0, color);
GabrielGoichman 2:e64c231f0abb 173 }
GabrielGoichman 2:e64c231f0abb 174 for (int16_t y=0; y < tft.height(); y+=6) {
GabrielGoichman 2:e64c231f0abb 175 tft.drawLine(0, tft.height()-1, tft.width()-1, y, color);
GabrielGoichman 2:e64c231f0abb 176 }
justinkim 0:b0981712db9b 177
GabrielGoichman 2:e64c231f0abb 178 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 179 for (int16_t x=0; x < tft.width(); x+=6) {
GabrielGoichman 2:e64c231f0abb 180 tft.drawLine(tft.width()-1, tft.height()-1, x, 0, color);
GabrielGoichman 2:e64c231f0abb 181 }
GabrielGoichman 2:e64c231f0abb 182 for (int16_t y=0; y < tft.height(); y+=6) {
GabrielGoichman 2:e64c231f0abb 183 tft.drawLine(tft.width()-1, tft.height()-1, 0, y, color);
GabrielGoichman 2:e64c231f0abb 184 }
justinkim 0:b0981712db9b 185 }
justinkim 0:b0981712db9b 186
GabrielGoichman 2:e64c231f0abb 187 void testfastlines(uint16_t color1, uint16_t color2)
GabrielGoichman 2:e64c231f0abb 188 {
GabrielGoichman 2:e64c231f0abb 189 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 190 for (int16_t y=0; y < tft.height(); y+=5) {
GabrielGoichman 2:e64c231f0abb 191 tft.drawFastHLine(0, y, tft.width(), color1);
GabrielGoichman 2:e64c231f0abb 192 }
GabrielGoichman 2:e64c231f0abb 193 for (int16_t x=0; x < tft.width(); x+=5) {
GabrielGoichman 2:e64c231f0abb 194 tft.drawFastVLine(x, 0, tft.height(), color2);
GabrielGoichman 2:e64c231f0abb 195 }
justinkim 0:b0981712db9b 196 }
justinkim 0:b0981712db9b 197
GabrielGoichman 2:e64c231f0abb 198
justinkim 0:b0981712db9b 199
GabrielGoichman 2:e64c231f0abb 200 void IniciandoMaquina()
GabrielGoichman 2:e64c231f0abb 201 {
GabrielGoichman 2:e64c231f0abb 202 tft.setTextWrap(true);
GabrielGoichman 2:e64c231f0abb 203 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 204 int x = 0;
GabrielGoichman 2:e64c231f0abb 205 while(x < 5) {
GabrielGoichman 2:e64c231f0abb 206 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 207 tft.setCursor(0,50);
GabrielGoichman 2:e64c231f0abb 208 tft.setTextColor(ST7735_WHITE);
GabrielGoichman 2:e64c231f0abb 209 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 210 tft.printf("Iniciando Pet-Finder");
GabrielGoichman 2:e64c231f0abb 211 tft.setCursor(0,100);
GabrielGoichman 2:e64c231f0abb 212 tft.printf("Aguarde");
GabrielGoichman 2:e64c231f0abb 213 wait_ms(100);
GabrielGoichman 2:e64c231f0abb 214 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 215 tft.setCursor(0,50);
GabrielGoichman 2:e64c231f0abb 216 tft.setTextColor(ST7735_WHITE);
GabrielGoichman 2:e64c231f0abb 217 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 218 tft.printf("Iniciando Pet-Finder");
GabrielGoichman 2:e64c231f0abb 219 tft.setCursor(0,100);
GabrielGoichman 2:e64c231f0abb 220 tft.printf("Aguarde...");
GabrielGoichman 2:e64c231f0abb 221 wait_ms(100);
GabrielGoichman 2:e64c231f0abb 222 x += 1;
justinkim 0:b0981712db9b 223 }
justinkim 0:b0981712db9b 224 }
justinkim 0:b0981712db9b 225
GabrielGoichman 2:e64c231f0abb 226
justinkim 0:b0981712db9b 227
GabrielGoichman 2:e64c231f0abb 228 void Alerta() {
GabrielGoichman 2:e64c231f0abb 229 tft.setTextWrap(true);
GabrielGoichman 2:e64c231f0abb 230 int x = 0;
GabrielGoichman 2:e64c231f0abb 231 while(x < 10) {
GabrielGoichman 2:e64c231f0abb 232 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 233 tft.setCursor(0,50);
GabrielGoichman 2:e64c231f0abb 234 tft.setTextColor(ST7735_WHITE);
GabrielGoichman 2:e64c231f0abb 235 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 236 tft.printf("!!ALERTA!!");
GabrielGoichman 2:e64c231f0abb 237 wait_ms(200);
GabrielGoichman 2:e64c231f0abb 238 tft.fillScreen(ST7735_RED);
GabrielGoichman 2:e64c231f0abb 239 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 240 tft.printf("!!ALERTA!!");
GabrielGoichman 2:e64c231f0abb 241 wait_ms(300);
GabrielGoichman 2:e64c231f0abb 242 x += 1;
GabrielGoichman 2:e64c231f0abb 243 }
GabrielGoichman 2:e64c231f0abb 244
justinkim 0:b0981712db9b 245 }
justinkim 0:b0981712db9b 246
GabrielGoichman 2:e64c231f0abb 247 void MenuPrincipal() {
GabrielGoichman 2:e64c231f0abb 248 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 249 tft.setCursor(0,0);
GabrielGoichman 2:e64c231f0abb 250 tft.setTextColor(ST7735_WHITE);
GabrielGoichman 2:e64c231f0abb 251 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 252 tft.printf("Pet-Finder");
GabrielGoichman 2:e64c231f0abb 253 tft.setCursor(0,40);
GabrielGoichman 2:e64c231f0abb 254 tft.printf("Data:");
GabrielGoichman 2:e64c231f0abb 255 tft.setCursor(0,55);
GabrielGoichman 2:e64c231f0abb 256 tft.printf("15/05/2017");
GabrielGoichman 2:e64c231f0abb 257 tft.setCursor(0,80);
GabrielGoichman 2:e64c231f0abb 258 tft.printf("Horario:");
GabrielGoichman 2:e64c231f0abb 259 tft.setCursor(0,95);
GabrielGoichman 2:e64c231f0abb 260 tft.printf("17h27");
GabrielGoichman 2:e64c231f0abb 261 wait_ms(200);
GabrielGoichman 2:e64c231f0abb 262
GabrielGoichman 2:e64c231f0abb 263 }
GabrielGoichman 2:e64c231f0abb 264
GabrielGoichman 2:e64c231f0abb 265 void Aguarde() {
justinkim 0:b0981712db9b 266 int x = 0;
GabrielGoichman 2:e64c231f0abb 267 while(x < 5) {
GabrielGoichman 2:e64c231f0abb 268 tft.fillScreen(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 269 tft.setCursor(0,70);
GabrielGoichman 2:e64c231f0abb 270 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 271 tft.printf("Aguarde...");
GabrielGoichman 2:e64c231f0abb 272 wait_ms(800);
GabrielGoichman 2:e64c231f0abb 273 x += 1;
justinkim 0:b0981712db9b 274 }
GabrielGoichman 2:e64c231f0abb 275 }
GabrielGoichman 2:e64c231f0abb 276
GabrielGoichman 2:e64c231f0abb 277 void Executando() {
GabrielGoichman 2:e64c231f0abb 278 int x = 0;
GabrielGoichman 2:e64c231f0abb 279 tft.fillScreen(ST7735_WHITE);
GabrielGoichman 2:e64c231f0abb 280 tft.setTextColor(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 281 while(x < 3) {
GabrielGoichman 2:e64c231f0abb 282 tft.fillScreen(ST7735_GREEN);
GabrielGoichman 2:e64c231f0abb 283 tft.setCursor(0,70);
GabrielGoichman 2:e64c231f0abb 284 tft.setTextSize(2);
GabrielGoichman 2:e64c231f0abb 285 tft.printf("Executando");
GabrielGoichman 2:e64c231f0abb 286 wait_ms(800);
GabrielGoichman 2:e64c231f0abb 287 tft.fillScreen(ST7735_WHITE);
GabrielGoichman 2:e64c231f0abb 288 tft.setTextColor(ST7735_BLACK);
GabrielGoichman 2:e64c231f0abb 289 tft.setCursor(0,70);
GabrielGoichman 2:e64c231f0abb 290 tft.printf("Executando");
GabrielGoichman 2:e64c231f0abb 291 wait_ms(400);
GabrielGoichman 2:e64c231f0abb 292 x += 1;
GabrielGoichman 2:e64c231f0abb 293
GabrielGoichman 2:e64c231f0abb 294 }
GabrielGoichman 2:e64c231f0abb 295 tft.fillScreen(ST7735_GREEN);
GabrielGoichman 2:e64c231f0abb 296 tft.setCursor(0,70);
GabrielGoichman 2:e64c231f0abb 297 tft.printf("Executando");
justinkim 0:b0981712db9b 298 }
GabrielGoichman 4:41b8a8713b49 299 */
justinkim 0:b0981712db9b 300
GabrielGoichman 2:e64c231f0abb 301 // ----------------------------------------------------------------------------------------------------------------
justinkim 0:b0981712db9b 302
GabrielGoichman 2:e64c231f0abb 303
GabrielGoichman 4:41b8a8713b49 304 void tone(int pin, float note, float duration) {
GabrielGoichman 4:41b8a8713b49 305 float periodo = 1/note;
GabrielGoichman 4:41b8a8713b49 306 Oito.period(periodo);
GabrielGoichman 4:41b8a8713b49 307 Oito.write(0.5f);
GabrielGoichman 4:41b8a8713b49 308 wait(duration);
GabrielGoichman 4:41b8a8713b49 309 Oito.write(0.0f);
GabrielGoichman 4:41b8a8713b49 310 }
GabrielGoichman 4:41b8a8713b49 311
GabrielGoichman 4:41b8a8713b49 312 // the loop routine runs over and over again forever:
GabrielGoichman 4:41b8a8713b49 313 void loop() {
GabrielGoichman 4:41b8a8713b49 314 //tone(pin, note, duration)
GabrielGoichman 4:41b8a8713b49 315 tone(8,LA3,Q);
GabrielGoichman 4:41b8a8713b49 316 wiat_ms(1000+Q);
GabrielGoichman 4:41b8a8713b49 317 tone(8,C1,Q);
GabrielGoichman 4:41b8a8713b49 318 wait_ms(1000+Q):
GabrielGoichman 4:41b8a8713b49 319
GabrielGoichman 4:41b8a8713b49 320
GabrielGoichman 4:41b8a8713b49 321 /*
GabrielGoichman 4:41b8a8713b49 322 wait_ms(1+Q); //wait_ms duration should always be 1 ms more than the note in order to separate them.
GabrielGoichman 4:41b8a8713b49 323 tone(8,LA3,Q);
GabrielGoichman 4:41b8a8713b49 324 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 325 tone(8,LA3,Q);
GabrielGoichman 4:41b8a8713b49 326 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 327 tone(8,F3,E+S);
GabrielGoichman 4:41b8a8713b49 328 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 329 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 330 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 331
GabrielGoichman 4:41b8a8713b49 332 tone(8,LA3,Q);
GabrielGoichman 4:41b8a8713b49 333 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 334 tone(8,F3,E+S);
GabrielGoichman 4:41b8a8713b49 335 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 336 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 337 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 338 tone(8,LA3,H);
GabrielGoichman 4:41b8a8713b49 339 wait_ms(1+H);
GabrielGoichman 4:41b8a8713b49 340
GabrielGoichman 4:41b8a8713b49 341 tone(8,E4,Q);
GabrielGoichman 4:41b8a8713b49 342 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 343 tone(8,E4,Q);
GabrielGoichman 4:41b8a8713b49 344 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 345 tone(8,E4,Q);
GabrielGoichman 4:41b8a8713b49 346 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 347 tone(8,F4,E+S);
GabrielGoichman 4:41b8a8713b49 348 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 349 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 350 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 351
GabrielGoichman 4:41b8a8713b49 352 tone(8,Ab3,Q);
GabrielGoichman 4:41b8a8713b49 353 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 354 tone(8,F3,E+S);
GabrielGoichman 4:41b8a8713b49 355 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 356 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 357 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 358 tone(8,LA3,H);
GabrielGoichman 4:41b8a8713b49 359 wait_ms(1+H);
GabrielGoichman 4:41b8a8713b49 360
GabrielGoichman 4:41b8a8713b49 361 tone(8,LA4,Q);
GabrielGoichman 4:41b8a8713b49 362 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 363 tone(8,LA3,E+S);
GabrielGoichman 4:41b8a8713b49 364 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 365 tone(8,LA3,S);
GabrielGoichman 4:41b8a8713b49 366 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 367 tone(8,LA4,Q);
GabrielGoichman 4:41b8a8713b49 368 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 369 tone(8,Ab4,E+S);
GabrielGoichman 4:41b8a8713b49 370 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 371 tone(8,G4,S);
GabrielGoichman 4:41b8a8713b49 372 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 373
GabrielGoichman 4:41b8a8713b49 374 tone(8,Gb4,S);
GabrielGoichman 4:41b8a8713b49 375 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 376 tone(8,E4,S);
GabrielGoichman 4:41b8a8713b49 377 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 378 tone(8,F4,E);
GabrielGoichman 4:41b8a8713b49 379 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 380 wait_ms(1+E);//PAUSE
GabrielGoichman 4:41b8a8713b49 381 tone(8,Bb3,E);
GabrielGoichman 4:41b8a8713b49 382 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 383 tone(8,Eb4,Q);
GabrielGoichman 4:41b8a8713b49 384 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 385 tone(8,D4,E+S);
GabrielGoichman 4:41b8a8713b49 386 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 387 tone(8,Db4,S);
GabrielGoichman 4:41b8a8713b49 388 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 389
GabrielGoichman 4:41b8a8713b49 390 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 391 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 392 tone(8,B3,S);
GabrielGoichman 4:41b8a8713b49 393 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 394 tone(8,C4,E);
GabrielGoichman 4:41b8a8713b49 395 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 396 wait_ms(1+E);//PAUSE QUASI FINE RIGA
GabrielGoichman 4:41b8a8713b49 397 tone(8,F3,E);
GabrielGoichman 4:41b8a8713b49 398 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 399 tone(8,Ab3,Q);
GabrielGoichman 4:41b8a8713b49 400 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 401 tone(8,F3,E+S);
GabrielGoichman 4:41b8a8713b49 402 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 403 tone(8,LA3,S);
GabrielGoichman 4:41b8a8713b49 404 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 405
GabrielGoichman 4:41b8a8713b49 406 tone(8,C4,Q);
GabrielGoichman 4:41b8a8713b49 407 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 408 tone(8,LA3,E+S);
GabrielGoichman 4:41b8a8713b49 409 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 410 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 411 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 412 tone(8,E4,H);
GabrielGoichman 4:41b8a8713b49 413 wait_ms(1+H);
GabrielGoichman 4:41b8a8713b49 414
GabrielGoichman 4:41b8a8713b49 415 tone(8,LA4,Q);
GabrielGoichman 4:41b8a8713b49 416 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 417 tone(8,LA3,E+S);
GabrielGoichman 4:41b8a8713b49 418 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 419 tone(8,LA3,S);
GabrielGoichman 4:41b8a8713b49 420 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 421 tone(8,LA4,Q);
GabrielGoichman 4:41b8a8713b49 422 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 423 tone(8,Ab4,E+S);
GabrielGoichman 4:41b8a8713b49 424 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 425 tone(8,G4,S);
GabrielGoichman 4:41b8a8713b49 426 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 427
GabrielGoichman 4:41b8a8713b49 428 tone(8,Gb4,S);
GabrielGoichman 4:41b8a8713b49 429 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 430 tone(8,E4,S);
GabrielGoichman 4:41b8a8713b49 431 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 432 tone(8,F4,E);
GabrielGoichman 4:41b8a8713b49 433 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 434 wait_ms(1+E);//PAUSE
GabrielGoichman 4:41b8a8713b49 435 tone(8,Bb3,E);
GabrielGoichman 4:41b8a8713b49 436 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 437 tone(8,Eb4,Q);
GabrielGoichman 4:41b8a8713b49 438 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 439 tone(8,D4,E+S);
GabrielGoichman 4:41b8a8713b49 440 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 441 tone(8,Db4,S);
GabrielGoichman 4:41b8a8713b49 442 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 443
GabrielGoichman 4:41b8a8713b49 444 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 445 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 446 tone(8,B3,S);
GabrielGoichman 4:41b8a8713b49 447 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 448 tone(8,C4,E);
GabrielGoichman 4:41b8a8713b49 449 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 450 wait_ms(1+E);//PAUSE QUASI FINE RIGA
GabrielGoichman 4:41b8a8713b49 451 tone(8,F3,E);
GabrielGoichman 4:41b8a8713b49 452 wait_ms(1+E);
GabrielGoichman 4:41b8a8713b49 453 tone(8,Ab3,Q);
GabrielGoichman 4:41b8a8713b49 454 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 455 tone(8,F3,E+S);
GabrielGoichman 4:41b8a8713b49 456 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 457 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 458 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 459
GabrielGoichman 4:41b8a8713b49 460 tone(8,LA3,Q);
GabrielGoichman 4:41b8a8713b49 461 wait_ms(1+Q);
GabrielGoichman 4:41b8a8713b49 462 tone(8,F3,E+S);
GabrielGoichman 4:41b8a8713b49 463 wait_ms(1+E+S);
GabrielGoichman 4:41b8a8713b49 464 tone(8,C4,S);
GabrielGoichman 4:41b8a8713b49 465 wait_ms(1+S);
GabrielGoichman 4:41b8a8713b49 466 tone(8,LA3,H);
GabrielGoichman 4:41b8a8713b49 467 wait_ms(1+H);
GabrielGoichman 4:41b8a8713b49 468
GabrielGoichman 4:41b8a8713b49 469 wait_ms(2*H);
GabrielGoichman 4:41b8a8713b49 470
GabrielGoichman 4:41b8a8713b49 471 */
GabrielGoichman 4:41b8a8713b49 472 }