miércoles, 27 de marzo de 2019

Sonidos

Al conectar la tarjeta por favor verificar lo siguiente:


  • En el Menú de Herramientas, seleccione "placa" y allí busque la placa "Adafruit Circuit Playground".
  •  Luego en el menú "herramientas" seleccione "Puerto" y allí verá el circuitPlayground, selecciónelo.


Vamos a crear sonidos con nuestra tarjeta CircuitPlayground
Utilizamos este sintaxis:

CircuitPlayground.playTone (262,500); // NOTA DO

Cambiamos los números para otras notas:

DO         262,500
RE          294,500
MI          330,500
FA          349,500
SOL       392,500
LA          440,500
SI           494,500
DO         523,500  más agudo

Escribimos el siguiente código:



// Copie utilizando el codigo camello (respete las mayúsculas en las palabras)
// CUIDADO CON LAS LLAVES y LOS PARENTESIS
#include <Adafruit_CircuitPlayground.h>
void setup() {   //incio del Programa
  Serial.begin(9600);
  CircuitPlayground.begin();
}
void loop() {//ciclo del Programa
      //sonidos
    CircuitPlayground.playTone (262,500); delay(50); // DO
    CircuitPlayground.playTone (294,500); delay(50); // RE
    CircuitPlayground.playTone (330,500); delay(50); // MI
    CircuitPlayground.playTone (349,500); delay(50); // FA
    CircuitPlayground.playTone (392,500); delay(50); // SOL
    CircuitPlayground.playTone (440,500); delay(50); // LA
    CircuitPlayground.playTone (494,500); delay(50); // SI
    CircuitPlayground.playTone (523,500); delay(50); // DO2
   }


Copiando y pegando algunas lineas de código podemos crear melodías sencillas.
Puedes tocar alguna de estas melodías:



ESTRELLITA DÓNDE ESTAS

DO-DO-SOLSOL-LA-LA-SOL
FA-FA-MI-MI-RE-RE-DO

 - = - = - = - = - = - = - = - = - = 

Arroz con leche 

Do Fa La Fa Fa 
Do Fa Fa La Sol 
La Sib La Sol Fa Mi Mi Do Do Re Mi Mi Fa 
= - = - = - = - = - = - = - = - = - = 
Título: Noche de paz 

Sol La Sol Mi 
Sol La Sol Mi 
re re Si do do Sol 
= - = - = - = - = - = - = - = - = - = 

Título: La cucaracha 

Do Do Do Fa La 
Do Do Do Fa La 
Fa Fa Mi Mi Re Re Do  
= - = - = - = - = - = - = - = - = - =


PROGRAMANDO ESTRELLITA DÓNDE ESTAS


// Copie utilizando el codigo camello (respete las mayusculas en las palabras)
// CUIDADO CON LAS LLAVES y LOS PARENTESIS
#include <Adafruit_CircuitPlayground.h>
void setup() {   //incio del Programa
  Serial.begin(9600);
  CircuitPlayground.begin();
}
void loop() {//ciclo del Programa
      //sonidos
    CircuitPlayground.playTone (262,500); delay(50); // DO
    CircuitPlayground.playTone (262,500); delay(50); // DO
    CircuitPlayground.playTone (392,500); delay(50); // SOL
    CircuitPlayground.playTone (392,500); delay(50); // SOL
    CircuitPlayground.playTone (440,500); delay(50); // LA
    CircuitPlayground.playTone (440,500); delay(50); // LA
    CircuitPlayground.playTone (392,500); delay(50); // SOL
    delay (1000);
    CircuitPlayground.playTone (349,500); delay(50); // FA
    CircuitPlayground.playTone (349,500); delay(50); // FA
    CircuitPlayground.playTone (330,500); delay(50); // MI
    CircuitPlayground.playTone (330,500); delay(50); // MI
    CircuitPlayground.playTone (294,500); delay(50); // RE
    CircuitPlayground.playTone (294,500); delay(50); // RE
    CircuitPlayground.playTone (262,500); delay(50); // DO 
    delay (1000);
}


Practica Banderas

Al conectar la tarjeta por favor verificar lo siguiente:


  • En el Menú de Herramientas, seleccione "placa" y allí busque la placa "Adafruit Circuit Playground".
  •  Luego en el menú "herramientas" seleccione "Puerto" y allí verá el circuitPlayground, selecciónelo.


Una forma de programar un neopixel es por medio de este comando.

      CircuitPlayground.setPixelColor( neopixel, ColorRed, ColorGreen, ColorBlue );


Utilizando este código, ¿puedes simular algunas banderas de algunos países?


// Copie utilizando el codigo camello (respete las mayusculas en las palabras)
// CUIDADO CON LAS LLAVES y LOS PARENTESIS
#include <Adafruit_CircuitPlayground.h>
//incio del Programa
void setup() {
  Serial.begin(9600);
  CircuitPlayground.begin();
}

//ciclo del Programa
void loop() {

      CircuitPlayground.setPixelColor( 0, 255, 255, 255 );
      CircuitPlayground.setPixelColor( 1, 255255, 255 );
      CircuitPlayground.setPixelColor( 2, 255255, 255 );
      CircuitPlayground.setPixelColor( 3, 255255, 255 );
      CircuitPlayground.setPixelColor( 4, 255255, 255 );
      CircuitPlayground.setPixelColor( 5, 255255, 255 );
      CircuitPlayground.setPixelColor( 6, 255255, 255 );
      CircuitPlayground.setPixelColor( 7, 255255, 255 );
      CircuitPlayground.setPixelColor( 8, 255255, 255 );
      CircuitPlayground.setPixelColor( 9, 255255, 255 );

      delay (5000);  //espera un segundo

   }


Puedes utilizar esta plantilla para ayudarte



Algunos colores que puedes utilizar son los siguientes:



Por ejemplo, la bandera de Costa Rica, podríamos simularla de la siguiente forma:


Y el código de la siguiente forma:


// Copie utilizando el codigo camello (respete las mayusculas en las palabras)
// CUIDADO CON LAS LLAVES y LOS PARENTESIS
#include <Adafruit_CircuitPlayground.h>
//incio del Programa
void setup() {
  Serial.begin(9600);
  CircuitPlayground.begin();
}

//ciclo del Programa
void loop() {

      CircuitPlayground.setPixelColor( 0, 00, 255 );
      CircuitPlayground.setPixelColor( 1, 255255, 255 );
      CircuitPlayground.setPixelColor( 2, 2550, 0 );
      CircuitPlayground.setPixelColor( 3, 255255, 255 );
      CircuitPlayground.setPixelColor( 4, 00, 255 );
      CircuitPlayground.setPixelColor( 5, 00, 255 );
      CircuitPlayground.setPixelColor( 6, 255255, 255 );
      CircuitPlayground.setPixelColor( 7, 2550, 0 );
      CircuitPlayground.setPixelColor( 8, 255255, 255 );
      CircuitPlayground.setPixelColor( 9, 00, 255 );

      delay (5000);  //espera un segundo


//Agrega aquí otras banderas. Copia el código de los neopixeles y pegalo antes de la llave del final
 
}

EJEMPLO: Banderas de Costa Rica y México