// constants won't change const int RELAY_PIN = 4; // the Arduino pin, which connects to the IN pin of relay int pinBuzzer = 12; int C__ = 261/4; int Cs__= 277/4; int D__ = 293/4 ; int Ds__= 311/4; int E__ = 329/4 ; int F__ = 349/4 ; int Fs__= 369/4; int G__ = 391/4 ; int Gs__= 415/4; int A__ = 440/4 ; int As__= 466/4; int B__ = 493/4 ; int C_ = 261/2; int Cs_= 277/2; int D_ = 293/2 ; int Ds_= 311/2; int E_ = 329/2 ; int F_ = 349/2 ; int Fs_= 369/2; int G_ = 391/2 ; int Gs_= 415/2; int A_ = 440/2 ; int As_= 466/2; int B_ = 493/2 ; int Sil = 5; int C = 261; int Cs= 277; int D = 293 ; int Ds= 311; int E = 329 ; int F = 349 ; int Fs= 369; int G = 391 ; int Gs= 415; int A = 440 ; int As= 466; int B = 493 ; int C2 =524; int Cs2 =555; int D2 =588; int Ds2 =623; int E2 =660; int F2 =699; int Fs2 =740; int G2 =784; int Gs2 =831; int A_2 = 880; int As2 =933; int B2 =988; int C3 =1047; int Cs3 =555*2; int D3 =588*2; int Ds3 =623*2; int E3 =660*2; int F3 =699*2; int Fs3 =740*2; int G3 =784*2; int Gs3 =831*2; int A_3 = 880*2; int As3 =933*2; int B3 =988*2; int tempo=90*2; int negra=60000/tempo; int semi = negra/4; int fusa =semi/2; int corch = 2*semi; int np = corch*3; int blanca = negra*2; int redonda = blanca*2; int rep = 3*negra; int bnp = 3*negra+3*corch; int r = redonda; int b = blanca; int n = negra; int c = corch; int s = semi; int f = fusa; int retardo = 100; void nota(int nota, int duracion){ tone(pinBuzzer,nota, duracion); delay(duracion); noTone(pinBuzzer); delay(duracion); } void setup() { // initialize digital pin as an output. pinMode(RELAY_PIN, LOW); delay(500); } void loop() { // bemoles // A B E // // sostenidos // G A D // // 1 //EnUnPueblo(); EnUnPueblo(); NoTienesNingunaPena(); PerdonameSiTedigo(); Fin(); Fin(); delay(1500); delay(500); } //C D F G void EnUnPueblo(){ // [1] int ttt = s/(3*2); nota(E2 ,ttt); nota(F2,ttt); nota(Fs2 ,ttt); nota(G2,n+c-ttt); nota(C3,c); nota(G2,c); nota(C3,c); nota(G2,c); nota(C3,s); nota(G2,c); // [2] //nota(G2,c); nota(G2,c); nota(F2,s); nota(E2,c); nota(F2,c); nota(G2,b); // [3] nota(A_2,n+c); nota(D3,c); nota(A_2,c); nota(D3,c); nota(A_2,c); nota(D3,s); nota(A_2,c); // [4] //nota(A_2,c); nota(A_2,c); nota(G2,s); nota(F2,c); nota(G2,c); nota(A_2,b); // [5] nota(D3 ,ttt); nota(Ds3,ttt); nota(E3 ,ttt); nota(F3,n+c-ttt); nota(F3,c); nota(E3,c); nota(E3,c); nota(D3,c); nota(D3,s); nota(D3,c); // [6] //nota(A_2,c); nota(C3,c); nota(B2,s); nota(C3,c); nota(D3,c); nota(E3,b); // [7] nota(D3 ,ttt); nota(Ds3,ttt); nota(E3 ,ttt); nota(F3,n+c-ttt); nota(F3,c); nota(E3,c); nota(E3,c); nota(D3,c); nota(D3,c); // [8] nota(C3,r); } void NoTienesNingunaPena(){ // [1] int ttt = s/(3*2); nota(E2 ,ttt); nota(F2,ttt); nota(Fs2 ,ttt); nota(G2,n+c-ttt); nota(C3,c); nota(G2,c); nota(C3,c); nota(G2,c); nota(C3,s); nota(G2,c); // [2] //nota(G2,c); nota(G2,c); nota(F2,s); nota(E2,c); nota(F2,c); nota(G2,b); // [3] nota(A_2,n+c); nota(D3,c); nota(A_2,c); nota(D3,c); nota(A_2,c); nota(D3,s); nota(A_2,c); // [4] //nota(A_2,c); nota(A_2,c); nota(G2,s); nota(F2,c); nota(G2,c); nota(A_2,b); // [5] nota(D3 ,ttt); nota(Ds3,ttt); nota(E3 ,ttt); nota(F3,n+c-ttt); nota(F3,c); nota(E3,c); nota(E3,c); nota(D3,c); nota(D3,s); nota(D3,c); // [6] //nota(A_2,c); nota(C3,c); nota(B2,s); nota(C3,c); nota(D3,c); nota(E3,b); // [7] nota(D3 ,ttt); nota(Ds3,ttt); nota(E3 ,ttt); nota(F3,n+c-ttt); nota(F3,c); nota(E3,c); nota(E3,c); nota(D3,c); nota(D3,c); // [8] nota(C3,b); nota(E3,b); } void PerdonameSiTedigo(){ // [9] nota(Sil,c); nota(A_2,n); nota(B2,c); nota(C3,c); nota(E3,c); nota(D3,c); nota(C3,s); nota(E3,c); // [10] //nota(E3,c); nota(E3,c); nota(C3,s); nota(B2,c); nota(C3,c); nota(D3,b); // [11] nota(Gs2,n+c); nota(A_2,c); nota(B2,c); nota(D3,c); nota(C3,c); nota(B2,s); nota(E3,c); // [12] nota(E3,c); nota(B2,s); nota(A_2,c); nota(B2,c); nota(C3,b); // [13] nota(A_2,n+c); nota(B2,c); nota(C3,c); nota(E3,c); nota(D3,c); nota(C3,s); nota(E3,c); // [14] //nota(E3,s); nota(E3,c); nota(C3,s); nota(B2,c); nota(C3,c); nota(D3,b); } void Fin(){ // [15] int ttt = s/(3*2); nota(D3 ,ttt); nota(Ds3,ttt); nota(E3 ,ttt); nota(F3,n+c-ttt); nota(F3,c); nota(E3,c); nota(E3,c); nota(D3,c); nota(D3,c); // [16] nota(A_2 ,ttt); nota(As2,ttt); nota(B2 ,ttt); nota(C3,r-ttt); }