Paso 4: Termina el hardware ya que está diseñado y subir el código a la Junta.
/*
: Control de volumen de la música y led bar usando el increíble 1sheeld
: Ahmed Ismail
: ahmed.ismail3115
: IDE de Arduino
*/
#define CUSTOM_SETTINGS
#define INCLUDE_SLIDER_SHIELD
#define INCLUDE_MUSIC_PLAYER_SHIELD
/ * Incluyen la biblioteca de 1Sheeld. */
#include
valor del octeto; / * define una variable para contener los valores de control deslizante. */
int led1 = 2; / * primero conectar led al pin 2. */
int led2 = 3; / * conectar segundo led al pin 3. */
int led3 = 4; / * tercera conexión led al pin 4. */
led4 int = 5; / * conexión a led al pin 5. */
int led5 = 6; / * conexión quinto led al pin 6. */
led6 int = 7; / * conexión sexto led al pin 7. */
int led7 = 8; / * conexión séptimo led al pin 8. */
led8 int = 9; / * conexión ochos led al pin 9. */
led9 int = 10; / * conexión noveno led al pin 10. */
int led10 = 11; / * conexión décimo led al pin 11. */
void setup() {}
/ * Ajustar las patillas del LED como salida. */
pinMode (led1, salida);
pinMode (led2, salida);
pinMode (led3, salida);
pinMode (led4, salida);
pinMode (led5, salida);
pinMode (led6, salida);
pinMode (led7, salida);
pinMode (led8, salida);
pinMode (led9, salida);
pinMode (led10, salida);
/ * Iniciar la comunicación. */
OneSheeld.begin();
}
void loop() {}
valor = Slider.getValue(); / * obtener el valor del control deslizante y mantener en la variable "valor". */
valor = mapa (valor, 0, 255, 0, 10); / * asignación de los valores analógicos de control deslizante en valores entre 0 y 10-* /
/ * para que lo entienda el volumen de la música. */
Switch (valor) / * interruptor entre los valores a determinar whicch LED para encender y que hacer de Speaker /
{
caso 1:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, LOW);
digitalWrite (LED 3, bajo);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 2:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, bajo);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 3:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 4:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 5:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 6:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, alta
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 7:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 8:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, HIGH);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
rotura;
caso 9:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, HIGH);
digitalWrite (led9, HIGH);
digitalWrite (led10, LOW);
rotura;
caso 10:
digitalWrite (LED 1, HIGH);
digitalWrite (led2, HIGH);
digitalWrite (LED 3, alto);
digitalWrite (led4, HIGH);
digitalWrite (led5, HIGH);
digitalWrite (led6, HIGH);
digitalWrite (led7, HIGH);
digitalWrite (led8, HIGH);
digitalWrite (led9, HIGH);
digitalWrite (led10, HIGH);
rotura;
por defecto:
digitalWrite (LED 1, bajo);
digitalWrite (led2, LOW);
digitalWrite (LED 3, bajo);
digitalWrite (led4, LOW);
digitalWrite (led5, LOW);
digitalWrite (led6, LOW);
digitalWrite (led7, LOW);
digitalWrite (led8, LOW);
digitalWrite (led9, LOW);
digitalWrite (led10, LOW);
}
MusicPlayer.setVolume(value); / * enviar el valor de slider a la volume.* de música /
MusicPlayer.play(); / * Enciende la música. */
}