Diferencia entre revisiones de «Medidor de parpadeo de luz»

Sin resumen de edición
Sin resumen de edición
Línea 5: Línea 5:
<pre>
<pre>


const int OVERLOAD_LED = 13;
#include "I2C_LCD.h"
 
const int COLLECTION_MS = 200;
const int COLLECTION_MS = 200;
const int DEAD_MS = 100;
const int SENSOR_LIMIT = 850;
const int SENSOR_MAX = 800;
 
I2C_LCD lcd(39);


void setup() {
void setup() {
   Serial.begin(9600);
   Wire.begin();
   pinMode(OVERLOAD_LED, OUTPUT);
   Wire.setClock(100000);
  lcd.begin(16, 2);
}
}


Línea 23: Línea 26:
     if (x < x_min) x_min = x;
     if (x < x_min) x_min = x;
   }
   }
   digitalWrite(OVERLOAD_LED, x_max > SENSOR_MAX);
 
   float ratio = (float) x_min / x_max;
  lcd.clear();
  Serial.println("0.0 1.0 " + String(ratio));
 
   delay(DEAD_MS);
   if (x_max > SENSOR_LIMIT) {
    lcd.center(1, "demasiada luz");
   } else {
    float ratio = (float)x_min / x_max;
    lcd.center(0, ("ratio = " + String(ratio)).c_str());
   }
}
}


</pre>
</pre>