Ir al contenido principal

Creación del Juego Ciclón y cuenta atrás


Aquí os traigo un nuevo proyecto  ilusionante y atractivo que he realizado con mis alumnos de 2FPB.

Este proyecto nació como iniciativa de mi alumno Joaquín, os tengo que decir que cuando un alumno me propone algún proyecto intento llevarlo a cabo , siempre que cumpla con las competencias de nuestro ciclo. Partimos de un ejemplo encontrado en Internet, y a partir de ese, hemos creado nuestra propia versión, y evidentemente mejorada :-)

El proyecto consiste en realizar el juego del ciclón y cuenta atrás.

JUEGO CICLÓN: Lo hemos implementado para uno y dos jugadores.  Disponemos de 50 luces Led , una de ellas está fija encendida  y otra que va girando por todas las luces Led, consiste en parar la  luz que gira en el Led que está encendido. El jugador que lo consiga pasará de nivel, incrementando la luz que gira de velocidad. Ganará el jugador que primero realice los 8 niveles de los que dispone nuestro Ciclón.

JUEGO DE CUENTA ATRÁS: Es un  juego para dos jugadores, en el inicio del juego cada jugador tiene 300 puntos, ganará el primero que llegue exactamente a 0. Se realizará por turnos rotatorios.

¿Qué hemos utilizado para la realización del proyecto?

  • Tira de 50 led direccionable.
  • Tarjeta de Arduino.
  • Dos botones Arcade.
  • Una placa PCB para las conexiones eléctricas.
  • Tablero 
  • Una impresora 3D para la decoración.
  • Cables.

Pasos para la realización del proyecto.

PASO 1. Cogimos un trozo de papel y dibujamos una circunferencia dividida en 50 trozos. Este dibujo nos guiará para saber dónde colocaremos cada led. Agradecemos al profe de matemáticas su ayuda para realizar dicho dibujo.



PASO 2. Aprovechando que se terminó el cable de red en clase , hemos utilizado los paneles que tenía dentro la caja.

PASO 3. Utilizando el papel realizado en el paso uno, señalamos en la tabla  los puntos donde vamos a colocar las luces Led y procedemos a su apertura con un trompo y broca 10. Este es un paso muy importante, puesto que repercute mucho en el resultado final.


PASO 4. Una vez abierto los agujeros en la tabla, pintamos el material en rojo y negro. La pintura llegó a muchos sitios :-)



PASO 5.El siguiente paso fué montar la estructura y colocar las luces led. Utilizando una placa de arduino , probamos que todos los led funcionaban correctamente. Hay que tener en cuenta que la tira de led es direccionable, quiere decir que además de darle corriente tenemos que idicar el led que se va a encender,

PASO 6 Montamos la circuitería del Ciclón y soldamos todas las conexiones. Para manejar la pantalla Led del juego, se ha instalado dos botones de arcade, tal y como podemos ver en las imágenes.

PASO 7 Montaje de los botones y de la pantalla LED.


PASO 8 Probamos un altavoz que posteriormente se instaló en la estructura y se conectó a arduino.


PASO 9 Una vez instalado todos los componente solo nos queda jugar y disfrutar de nuestra máquina.




A continuación se adjunta el fichero del esquema eléctrico del juego del Ciclón:

 
Por último , adjunto el código utilizado para el juego:

#include "FastLED.h"
#include <LiquidCrystal.h>

//****CONFIGURACION LCD
LiquidCrystal lcd(6, 8, 10, 11, 12, 13); //    ( RS, EN, d4, d5, d6, d7)

#define NUM_LEDS 50 // DEFINIMMOS EL NUMERO DE LED

#define CENTER_LED 29 //DEFINIMOS EL LED CENTRAL DEL JUEGO

#define DATA_PIN 7 //DEFINIMOS EL PIN DE LOS DATOS DEL LED

#define BRIGHTNESS 64 //BRILLO DE LOS LED range 0-64

//DEFINIMOS LA DIFICULTAD DEL JUEGO, LO DIVIDIMOS EN 8 NIVELES
#define NIVEL1 1
#define NIVEL2 2
#define NIVEL3 3
#define NIVEL4 4
#define NIVEL5 5
#define NIVEL6 6
#define NIVEL7 7
#define NIVEL8 8

//definimos la dificultad del juego
int dificultadP1=1; //Controla la dificultad del player 1
int dificultadP2=1; //Controla la dificultad del player 2
bool enableP1=true; //controla si esta el player 1 o el 2 true=habilitado p1 false habilitado player 2

// Definimos el array de LEDS
CRGB leds[NUM_LEDS]; //configurar el bloque de memoria que ser utilizado para almacenar y manipular los datos del led

// Did player win this round? This tag is used for difficulty parameters.
bool wonThisRound = false;

// Starting location of the cycling light
int LEDaddress = 0;

// Is game running?
bool Playing = true;

// Is this the first win?
bool CycleEnded = true;

// Botones
const int buttonRed =5; // DEfinimos el botón ROJO
const int buttonWhite = 9; //Definimos el botón blanco
int buttonStateWhite = 0;
int buttonStateRed = 0;

//VBLES PARA EL JUEGO DE CUENTA ATRAS
#define PUNTOSCUENTAATRAS 300
int puntosJugador1=PUNTOSCUENTAATRAS;
int puntosJugador2=PUNTOSCUENTAATRAS;

char* OPCION_JUEGO="INICIO"; //VBLE QUE CONTROLA EL MENU DE JUEGO
bool OPCION_SALIR=false;
//****Vbles para la musica
#define  c3    7634
#define  d3    6803
#define  e3    6061
#define  f3    5714
#define  g3    5102
#define  a3    4545
#define  b3    4049
#define  c4    3816    // 261 Hz
#define  d4    3401    // 294 Hz
#define  e4    3030    // 329 Hz
#define  f4    2865    // 349 Hz
#define  g4    2551    // 392 Hz
#define  a4    2272    // 440 Hz
#define  a4s   2146
#define  b4    2028    // 493 Hz
#define  c5    1912    // 523 Hz
#define  d5    1706
#define  d5s   1608
#define  e5    1517    // 659 Hz
#define  f5    1433    // 698 Hz
#define  g5    1276
#define  a5    1136
#define  a5s   1073
#define  b5    1012
#define  c6    955
 #define  R     0      // Define a special note, ‘R’, to represent a rest
int speakerOut = 4;
int rest_count = 50;
int toneM = 0;
int beat = 0;
long duration  = 0;
long tempo = 10000;
int melody1[] = {  a4, R,  a4, R,  a4, R,  f4, R, c5, R,  a4, R,  f4, R, c5, R, a4, R,  e5, R,  e5, R,  e5, R,  f5, R, c5, R,  g5, R,  f5, R,  c5, R, a4, R};
int beats1[]  = {  50, 20, 50, 20, 50, 20, 40, 5, 20, 5,  60, 10, 40, 5, 20, 5, 60, 80, 50, 20, 50, 20, 50, 20, 40, 5, 20, 5,  60, 10, 40, 5,  20, 5, 60, 40};
int MAX_COUNT = sizeof(melody1) / 2;

int beats2[]  = {  21,  21, 21,  128,  128,   21,  21,  21, 128, 64,  21,  21,  21, 128, 64,  21, 21,  21, 128 };
//*****Fin vbles de musicca
void setup() {
  //******CONFIGURACION LCD
    lcd.begin(16, 2); // Fijar el numero de caracteres y de filas
    //lcd.print("IES ALMUDEYNE"); // Enviar el mensaje
    setLCD (0,0," IES. ALMUDEYNE ");
    setLCD (0,1,"     2 FPB      ") ;
  //CONFIGURACION DE LA TIRA DE LED
   FastLED.addLeds<NEOPIXEL, DATA_PIN>(leds, NUM_LEDS);//Esto le dice a la biblioteca que hay una cadena de NEOPIXEL en el pin 7 (recuerde, el valor en el que se estableció DATA_PIN), y esos leds usarán la matriz led leds, y hay NUM_LEDS (también conocidos como 60).
   FastLED.setBrightness(BRIGHTNESS);

   //CONFIGURAMOS LOS DOS BOTONES QUE TENEMOS COMO ENTRADA
   pinMode(buttonWhite, INPUT); //BOTON BLANCO
   pinMode(buttonRed,INPUT);    //BOTON ROJO

   pinMode(speakerOut, OUTPUT); //ALTAVOCES
   
   Serial.begin(9600);
   cancionStar();
}

void loop() {
  
  
      
   if ( strcmp(OPCION_JUEGO, "CICLON1PLAYER") == 0 || strcmp(OPCION_JUEGO, "CICLON2PLAYER") == 0)
   {  
    
    jugarCiclon();
   }
   else if ( strcmp(OPCION_JUEGO, "CUENTAATRAS") == 0 )
    jugarCuentaAtras();
   else
    Menu();
  
   
   
}
//Metodo que gestiona el menu del juego.
void Menu ()
{
  
  buttonStateWhite = digitalRead(buttonWhite);
  buttonStateRed = digitalRead(buttonRed);
 
    
 
  if (strcmp(OPCION_JUEGO, "INICIO") == 0)
  {
    setLCD (0,0,"1.-JUEGO CICLON ");
    setLCD (0,1,"2.-CUENTA ATRAS ");
    OPCION_JUEGO="JUEGO";
   
  }
  else if ( buttonStateRed == 1 && strcmp(OPCION_JUEGO, "JUEGO") == 0 )
  {
      OPCION_JUEGO="CICLON";
      setLCD (0,0,"1 JUGADOR       ");
      setLCD (0,1,"2 JUGADORES     ");
            
  }
  else if ( buttonStateRed == 1 && strcmp(OPCION_JUEGO, "CICLON") == 0 )
  {
      OPCION_JUEGO="CICLON1PLAYER";
      setLCD (0,0,"COMIENZA PARTIDA");
      setLCD (0,1,"JUGADOR 1       ");
            
  }
   else if ( buttonStateWhite == 1 && strcmp(OPCION_JUEGO, "CICLON") == 0 )
  {
      OPCION_JUEGO="CICLON2PLAYER";
      setLCD (0,0,"COMIENZA PARTIDA");
      setLCD (0,1,"JUGADOR 1       ");
         
      
  }
   else if ( buttonStateWhite == 1 && strcmp(OPCION_JUEGO, "JUEGO") == 0 )
  { //HA PULSADO LA OPCION DE JUEGO DE CUENTA ATRAS
      OPCION_JUEGO="CUENTAATRAS";
      setLCD (0,0,"EL PRIMERO EN   ");
      setLCD (0,1,"LLEGAR A 0  GANA");
      delay(2000);
      
      enableP1=true; //Comienza player 1
      cuentaAtrasLCD();
  }



}
void salirDeljuego()
{
   buttonStateRed = digitalRead(buttonRed);
   bool salir = false;
   bool nosalir=false;
  while ( buttonStateRed == 1 )
    {
        setLCD (0,0,"Deseas salir    ");
        setLCD (0,1,"Si Bot R/N Bot B");
        salir=digitalRead(buttonRed);
        nosalir=digitalRead(buttonWhite);
        
        if (nosalir == true)
          {
            Serial.println("NO SALIR");
            buttonStateRed = 0;
          }
        else if (salir == true)
          {
            Serial.println("SALIR");
            reinicioJuegos();
            buttonStateRed=0;
          }
    }
    
        
    
}
void jugarCuentaAtras()
{
 salirDeljuego();
      
   buttonStateWhite = digitalRead(buttonWhite);
   if (buttonStateWhite == HIGH)
  {
    //Inicializamos los Leds
    for (int i = 0; i < NUM_LEDS; i++)
     {
      leds [i] = CRGB::Black;
     }
    leds[CENTER_LED] = CRGB::Red;
    leds[LEDaddress] = CRGB::Green;

     FastLED.show();
         if (CycleEnded = true)
          {
            if ( LEDaddress < CENTER_LED )
                  {
                   
                      if (enableP1 == true && (puntosJugador1 > (LEDaddress+21)))
                          puntosJugador1=puntosJugador1-LEDaddress-21;
                      else if (enableP1 == false && puntosJugador2 >= (LEDaddress+21))
                          puntosJugador2=puntosJugador2-LEDaddress-21;

               
                      enableP1=!enableP1; //Cambiamos de usurio
                  }
            else if ( LEDaddress > CENTER_LED )
                  {
                  
                      if (enableP1 == true && ((puntosJugador1 >= (LEDaddress-29))))
                          puntosJugador1=puntosJugador1-LEDaddress+29;
                      else if (enableP1 == false && puntosJugador2 >= (LEDaddress-29))
                          puntosJugador2=puntosJugador2-LEDaddress+29;
                    
                    
                      enableP1=!enableP1; //Cambiamos de usurio
                  }
            else
                  { //Para el led en el central
                     if (enableP1 == true && (puntosJugador1 >= 50))
                          puntosJugador1=puntosJugador1-50;
                     else if (enableP1 == false && puntosJugador2 >= 50)
                          puntosJugador2=puntosJugador2-50;
                  }
            cuentaAtrasLCD(); 
            
               CycleEnded = false;
            }
              LEDaddress = 0; 
            delay(250);
            buttonStateWhite = digitalRead(buttonWhite);
            if (buttonStateWhite == LOW)
            {
             Playing = true;
            }
            if (puntosJugador1 == 0) //Gana Jugador 1
              {
                Playing = false;
                setLCD (0,0,"   GANADOR      ");
                setLCD (0,1,"   JUGADOR 1    ") ;
                fadeall();
                cancionEspana();
                reinicioJuegos();
              }
            else if (puntosJugador2 == 0 ) //Gana Jugador 2
              {
                Playing = false;
                setLCD (0,0,"   GANADOR      ");
                setLCD (0,1,"   JUGADOR 2    ") ;
                fadeall();
                cancionEspana();
                reinicioJuegos();
              }
  }
 if(Playing)
  {
       for (int i = 0; i < NUM_LEDS; i++)
        {
          leds[i] = CRGB::Black; //Turns off all the leds
        }
        leds[CENTER_LED] = CRGB::Red; //Sets center led color to green
        leds[LEDaddress] = CRGB::Green; //Sets cyling led color to red
        FastLED.show(); //Initializes light cycle
        LEDaddress++; //Sets light cycle to one led at a time
        if (LEDaddress == NUM_LEDS)
        {
          LEDaddress = 0;
        }
        
         delay(getTime(8)); //Dificultad 8
         buttonStateWhite = digitalRead(buttonWhite);
          if (buttonStateWhite == HIGH)
          {
           Playing = false;
           CycleEnded = true;
          }
  } 
}

void jugarCiclon ()
{
  salirDeljuego();
  //END GAME
  buttonStateWhite = digitalRead(buttonWhite);
 
  if (buttonStateWhite == HIGH)
  {
    Playing = false; //User has pressed the button, and the LED has stopped on the winning address.
     for (int i = 0; i < NUM_LEDS; i++)
     {
      leds [i] = CRGB::Black;
     }
    leds[CENTER_LED] = CRGB::Red;
    leds[LEDaddress] = CRGB::Green; 
    
    FastLED.show();
    if (CycleEnded = true)
    {
      
      int diff = abs(CENTER_LED - LEDaddress); //Encuentra la distancia entre el led seleccionado y el led central
      if (diff == 0)
      {
        wonThisRound = true; //Player sucessfully beat the level
       if (enableP1 == true)
       {
                      Serial.println("entra...P1");
                      if (dificultadP1 != NIVEL8)
                       {
                        for (int i = 0; i < 2; i++)
                         {
                          cylon();
                         }
                         increaseDifficulty();
                         cambiarVisionLCD();
                       }
                      if (dificultadP1 == NIVEL8)
                       {
                        for (int i = 0; i < 8; i++)
                         {
                          cylon();
                         }
                        reinicioJuegos(); 
                        setLCD (0,0,"   GANADOR      ");
                        setLCD (0,1,"   JUGADOR 1    ") ;
                        cancionEspana();
                        //delay(1000);
                        
                       }
                      
                            
                      wonThisRound = false;
       }
       else
       {
        
                      if (dificultadP2 != NIVEL8)
                       {
                        for (int i = 0; i < 2; i++)
                         {
                          cylon();
                         }
                         increaseDifficulty();
                         cambiarVisionLCD();
                       }
                      if (dificultadP2 == NIVEL8)
                       {
                        for (int i = 0; i < 8; i++)
                         {
                          cylon();
                         }
                        reinicioJuegos(); 
                        setLCD (0,0,"   GANADOR      ");
                        setLCD (0,1,"   JUGADOR 2    ") ;
                        cancionEspana();
                        //delay(1000);
                       }
                      
                      wonThisRound = false;
       }
      }
       else
      {
                    delay(1000);  
                    for (int i = 0; i < 2; i++)
                     {
                      flash();
                     }
                     if (strcmp(OPCION_JUEGO, "CICLON2PLAYER") == 0)
                     {
                      
                        if (enableP1 == true )
                           enableP1=false;      
                         else
                          enableP1=true;
                      
                     }
                   cambiarVisionLCD();  
      }
        CycleEnded = false;
      }
    LEDaddress = 0; 
    delay(250);
    buttonStateWhite = digitalRead(buttonWhite);
    if (buttonStateWhite == LOW)
    {
     Playing = true;
    }
    
  }
  
  //PLAYING
  if(Playing)
  {
    for (int i = 0; i < NUM_LEDS; i++)
    {
      leds[i] = CRGB::Black; //Turns off all the leds
    }
    leds[CENTER_LED] = CRGB::Red; //Sets center led color to green
    leds[LEDaddress] = CRGB::Green; //Sets cyling led color to red
    FastLED.show(); //Initializes light cycle
    LEDaddress++; //Sets light cycle to one led at a time
    if (LEDaddress == NUM_LEDS)
    {
      LEDaddress = 0;
    }
    if (enableP1==true)
      delay(getTime(dificultadP1));
    else
     delay(getTime(dificultadP2));
    buttonStateWhite = digitalRead(buttonWhite);
    if (buttonStateWhite == HIGH)
    {
     Playing = false;
     CycleEnded = true;
    }
 }
}
void reinicioJuegos()
{
  dificultadP1=1;
  dificultadP2=1;
  enableP1 = true;
  OPCION_JUEGO="INICIO";
  puntosJugador1=PUNTOSCUENTAATRAS;
  puntosJugador2=PUNTOSCUENTAATRAS;
}
//FUNCION PARA MOSTRAR DATOS EN EL LCD
void setLCD (int column, int line, String texto)
{
   lcd.setCursor(column, line);  // Coloca el cursor en la columna y linea indicada
   lcd.print(texto); //Escribe el texto indicado
   delay(100);
}
//Level Parameters
int getTime(int diff) // Returns time delay for led movement base on difficulty
{
  int timeValue = 0;
  switch (diff) 
  {
    case NIVEL1:
      timeValue = 100;
      break;
    case NIVEL2:
      timeValue = 80;
      break;
    case NIVEL3:
      timeValue = 60;
      break;
    case NIVEL4:
      timeValue = 40;
      break;
    case NIVEL5:
      timeValue = 30;
      break;
    case NIVEL6:
      timeValue = 20;
      break;
    case NIVEL7:
      timeValue = 13;
      break;
    case NIVEL8:
      timeValue = 7;
  }
  return timeValue;// Return the delay amount
}
void cuentaAtrasLCD()
{
      setLCD (0,0,"JUGADOR 1:      ");
      setLCD (12,0,String(puntosJugador1));
      
      setLCD (0,1,"JUGADOR 2:      ");
      setLCD (12,1,String(puntosJugador2));
      
      if (enableP1 == true)
        {
          setLCD (15,0,"*");
          setLCD (15,1," ");
        }
      else
        {
          setLCD (15,0," ");
          setLCD (15,1,"*");
        }
       
}
void cambiarVisionLCD()
{
  //Serial.println("Cambia Visibiliada");
   if (enableP1==true)
   {
    //Serial.println("JUGADOR 1");
    setLCD (0,0,"JUGADOR 1       ");
    setLCD (0,1,"NIVEL           ") ;
    setLCD (7,1,String(dificultadP1));
   }
   else
   {
    //Serial.println("JUGADOR 2");
    setLCD (0,0,"JUGADOR 2       ");
    setLCD (0,1,"NIVEL           ") ;
    setLCD (7,1,String(dificultadP2));
   }
}
//Winning difficulty increase parameters
void increaseDifficulty() 
{
  if (enableP1 == true)
  {
    if (dificultadP1 != NIVEL8 && wonThisRound) 
    {
      dificultadP1++;
    }
    //setLCD (0,0,"JUGADOR 1       ");
    //setLCD (0,1,"NIVEL           ") ;
    //setLCD (7,1,String(dificultadP1));
  }
  else
  {
  if (dificultadP2 != NIVEL8 && wonThisRound) 
    {
      dificultadP2++;
    }
    //setLCD (0,0,"JUGADOR 2       ");
    //setLCD (0,1,"NIVEL           ") ;
    //setLCD (7,1,String(dificultadP2));
  }
}

//*****Efecto de luces cuando pierde
void flash()
  fill_solid(leds, NUM_LEDS, CRGB::Red);
  FastLED.show();
  delay(500);
  fill_solid(leds, NUM_LEDS, CRGB::Black);
  FastLED.show();
  delay(500);
}

//Efecto Luces cuando Gana
void fadeall() 
  for(int i = 0; i < NUM_LEDS; i++) { leds[i].nscale8(250); } 
}

void cylon() 
  static uint8_t hue = 0;
  Serial.print("x");
  // First slide the led in one direction
  for(int i = 0; i < NUM_LEDS; i++) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show(); 
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
  Serial.print("x");

  // Now go in the other direction.  
  for(int i = (NUM_LEDS)-1; i >= 0; i--) {
    // Set the i'th led to red 
    leds[i] = CHSV(hue++, 255, 255);
    // Show the leds
    FastLED.show();
    // now that we've shown the leds, reset the i'th led to black
    // leds[i] = CRGB::Black;
    fadeall();
    // Wait a little bit before we loop around and do it again
    delay(10);
  }
  
}

void cancionStar() {
for (int i=0; i<MAX_COUNT; i++) {
toneM = melody1[i];
beat = beats1[i];
duration = beat * tempo;

long elapsed_time = 0;
if (toneM > 0) {

while (elapsed_time < duration) {
digitalWrite(speakerOut,HIGH);
delayMicroseconds(toneM / 2);
digitalWrite(speakerOut, LOW);
delayMicroseconds(toneM / 2);
elapsed_time += (toneM);

       }


}
else {
for (int j = 0; j < rest_count; j++) {
delayMicroseconds(duration);
}

}
}
}

void cancionEspana()
{
   tone(speakerOut,392,1000);

  delay(1000);

    tone(speakerOut,293.67,1000);

  delay(1000);

    tone(speakerOut,493.88,1000);

  delay(1000);

  tone(speakerOut,392,500);

  delay(500);

 tone(speakerOut,587.33,500);

  delay(500);

  tone(speakerOut,535.25,500);

  delay(500);

    tone(speakerOut,493.88,500);

  delay(500);    //Si alta semicorchea

    tone(speakerOut,440,500);

  delay(500);

  tone(speakerOut,392,500);

  delay(500); //sol semicorchea

  tone(speakerOut,392,500); //la otra sol semicorchea

  delay(500);

tone(speakerOut,369.99,500);

  delay(500); //fa sostenido

tone(speakerOut,329.63,500);

  delay(500);

  tone(speakerOut,293.67,500);

  delay(500);  //fin primer renglon



  tone(speakerOut,392,1000);

  delay(1000);

   tone(speakerOut,440,1000);

  delay(1000);

    tone(speakerOut,493.88,1000);

  delay(1500);  //aqui va el primer silencio

    tone(speakerOut,587.33,500);

  delay(500);

  tone(speakerOut,523.25,500);

  delay(500);

  tone(speakerOut,493.88,500);

  delay(500);  //si semicorchea

  tone(speakerOut,440,500);

  delay(500);

  tone(speakerOut,392,500);

  delay(500);  //sol antes de blanca

  tone(speakerOut,587.33,2000);

  delay(2000);   //fin segunda linea







    tone(speakerOut,392,1000);

  delay(1000);

    tone(speakerOut,293.67,1000);

  delay(1000);

    tone(speakerOut,493.88,1000);

  delay(1000);

  tone(speakerOut,392,500);

  delay(500);

 tone(speakerOut,587.33,500);

  delay(500);

  tone(speakerOut,535.25,500);

  delay(500);

    tone(speakerOut,493.88,500);

  delay(500);    //Si alta semicorchea

    tone(speakerOut,440,500);

  delay(500);

  tone(speakerOut,392,500);

  delay(500); //sol semicorchea

  tone(speakerOut,392,500); //la otra sol semicorchea

  delay(500);

tone(speakerOut,369.99,500);

  delay(500); //fa sostenido

tone(speakerOut,329.63,500);

  delay(500);

  tone(speakerOut,293.67,500);

  delay(500);  //fin primer renglon



  tone(speakerOut,392,1000);

  delay(1000);

   tone(speakerOut,440,1000);

  delay(1000);

    tone(speakerOut,493.88,1000);

  delay(1500);  //aqui va el primer silencio

    tone(speakerOut,587.33,500);

  delay(500);

  tone(speakerOut,523.25,500);

  delay(500);

  tone(speakerOut,493.88,500);

  delay(500);  //si semicorchea

  tone(speakerOut,440,500);

  delay(500);

  tone(speakerOut,392,500);

  delay(500);  //sol antes de blanca

  tone(speakerOut,587.33,2000);

  delay(2000);   //fin de lo que se repite

  

  tone(speakerOut,587.33,1000);

  delay(1000); 

  tone(speakerOut,493.88,750);

  delay(750); 

    tone(speakerOut,587.33,250);   //prueba de tiempo

  delay(250); 

    tone(speakerOut,523.25,1000);

  delay(1000); 

  tone(speakerOut,440,750);

  delay(750); 

    tone(speakerOut,523.25,250);   //prueba de tiempo

  delay(250);   //fin segunda parte



  tone(speakerOut,493.88,1000);

  delay(1000); 



  tone(speakerOut,392,750);

  delay(750); 

  tone(speakerOut,493.88,250);   

  delay(250); 

  tone(speakerOut,440,500);

  delay(500);

  tone(speakerOut,293.67,500);

  delay(500);

  tone(speakerOut,329.63,500);

  delay(500);

  tone(speakerOut,369.99,500); //fa sostenido

  delay(500);

  tone(speakerOut,392,1000);

  delay(1000);

  tone(speakerOut,440,1000);

  delay(1000);



  tone(speakerOut,493.88,750);

  delay(750);

  tone(speakerOut,523.25,250);

  delay(250);



  tone(speakerOut,587.33,500);

  delay(500);

  tone(speakerOut,523.25,500);

  delay(500);

  tone(speakerOut,493.88,1000);

  delay(1000);

  tone(speakerOut,440,1000);

  delay(1000);

  tone(speakerOut,392,2000);

  delay(2500);
}


Comentarios

Entradas populares de este blog

UltraIso y montar Unidad virtual

Descargar e instalar VirtualBox

Instalar W8.1 en VirtualBox