PROYECTO FINAL




PROYECTO FINAL:





Prototipo para la población de estudiantes sordos, se pretende que cuando suene el timbre de cambio de lección o recreo se emita una luz de forma simultánea con el sonido, de esta manera los estudiantes sordos tendrán las mismas condiciones que los estudiantes oyentes.










CÓDIGO DEL PROGRAMA:

#include <Adafruit_CircuitPlayground.h>
#include <Adafruit_Circuit_Playground.h>

//Inicializacion de Variables
int pinDelBoton = 10; // Se identifica el pin a usar con el boton
int boton = 50;  // Variable que captura valor del boton
int luz = 9; // Identifica el pin a usar por el bombillo LED
int inactivo=0;
int activo=0;

void setup() {
  //Inicializacion de componentes
  CircuitPlayground.begin();     // Inicializa la tarjeta
  pinMode (pinDelBoton, INPUT);  // Inicializa pin de entrada del boton
  pinMode (luz, OUTPUT);         // Inicializa pin de salida del LED
}

void loop() {
  //Codigo a ejecutar repetidamente
  inactivo=digitalRead(pinDelBoton);
  if (inactivo==1 && activo==0)
  {
    activo=1;
  }
  else if (inactivo==1 && activo==1)
  {
    activo=0;
  }

  encenderLed();
}

void encenderLed()
{
  if (CircuitPlayground.readCap(pinDelBoton) > boton )
  {
    CircuitPlayground.playTone(500, 50,1); // Emite sonido
    pinMode(luz,HIGH); // Envia señal de luz al LED
    delay (50); // Tiempo de espera de 1 segundo
  }
  else
  {
    pinMode(luz,LOW); // Apaga la luz
  }
}

No hay comentarios:

Publicar un comentario