/*
Proyecto 7a
Calibramos la fotorresistencia con ayuda de un botón
*/
// Usamos el pin analógico A1 para leer el voltaje
const int PinVoltaje = A1;
const int PinBoton = 6;
int Medida = 1;
void setup() {
pinMode(PinBoton, INPUT);
Serial.begin(9600);
Serial.print("Medida");
Serial.println("Voltaje ");
Serial.print("----- ");
Serial.println("----- ");
}
void loop(){
float Voltaje;
int EstadoBoton;
EstadoBoton = digitalRead(PinBoton);
Voltaje = LeerVoltaje(PinVoltaje);
if (EstadoBoton = HIGH)
// Se mandan los datos de Aruino al monitor de serie
{
Serial.print(" ");
Serial.print(Medida);
Serial.print(" ");
Serial.println(Voltaje);
Medida++;
delay(1000);
}}
float LeerVoltaje(int Pin){
// Definimos la función LeerVoltaje()
return (analogRead(Pin) * 5./ 1024.);}