#include "SoftwareSerial.h" const int Rx = 1; // this is physical pin 2 const int Tx = 2; // this is physical pin 3 const long A = 1000; //Resistencia en oscuridad en KΩ const int B = 15; //Resistencia a la luz (10 Lux) en KΩ const int Rc = 10; //Resistencia calibracion en KΩ const int LDRPin = A7; //Pin del LDR 6 ATTiny int V; int ilum; int cont = 0; SoftwareSerial mySerial(Rx, Tx); void setup(){ pinMode(Rx, INPUT); pinMode(Tx, OUTPUT); mySerial.begin(9600); // send serial data at 9600 bits/sec } void loop() { V = analogRead(LDRPin); //ilum = ((long)(1024-V)*A*10)/((long)B*Rc*V); //usar si LDR entre GND y A0 ilum = ((long)V*A*10)/((long)B*Rc*(1024-V)); //usar si LDR entre A0 y Vcc (como en el esquema anterior) mySerial.println(ilum); mySerial.println(cont); delay(1000); cont++; }