Paso 5: El programa
/*
Célula solar Tester 15V-1A
por Mike Soniat
08 de septiembre de 2012
*/
const int RxPin = 3;
#include < SoftwareSerial.h >
SoftwareSerial lcdPanel = SoftwareSerial (255, RxPin);
int voltPin = 1;
int ampPin = 2;
int readVolts = 0;
int readAmps = 0;
int maxVolts = 15; Debe coincidir con los resistores del circuito de voltaje
Float voltageFactor = 0;
voltaje del flotador = 0;
corriente del flotador = 0;
Float potencia = 0;
const int clearIt = 12;
const int cr = 13;
const int backLightOn = 17;
const int backLightOff = 18;
void setup() {}
pinMode (RxPin, salida);
digitalWrite (RxPin, alto);
lcdPanel.begin(9600);
startUp();
}
void loop()
{
medir el voltaje de
readVolts = analogRead(voltPin);
Si (readVolts > 0)
{
mientras (readVolts > 0)
{
readVolts = analogRead(voltPin);
Si (readVolts > 0)
{
voltageFactor = 1024 / maxVolts;
voltaje = readVolts / voltageFactor;
clearLCD();
lcdPanel.print ("lectura");
lcdPanel.print(voltage);
lcdPanel.print("V");
lcdPanel.write(cr);
lcdPanel.print ("mueva interruptor a la A");
}
Delay(1000);
}
}
otra cosa
{
startUp();
}
interruptor para circuito de corriente
readAmps = analogRead(ampPin);
mientras (readAmps > 0)
{
Si (tensión > 0)
{
readAmps = analogRead(ampPin);
actual = readAmps;
Potencia = Voltaje * corriente;
clearLCD();
lcdPanel.print(voltage);
lcdPanel.print ("V");
lcdPanel.print ("I =");
lcdPanel.print(current);
lcdPanel.print("mA");
lcdPanel.write(cr);
lcdPanel.print(power);
lcdPanel.print("mW");
Delay(1000);
}
Else {}
readAmps = analogRead(ampPin);
}
}
Delay(1000);
}
void clearLCD()
{
lcdPanel.write(clearIt); Claro
Delay(5);
}
startUp() vacío
{
clearLCD();
lcdPanel.write(backLightOn);
lcdPanel.print ("15V - 1A Solar");
lcdPanel.write(cr);
lcdPanel.print "(probador de la célula del);
Delay(3000);
clearLCD();
lcdPanel.print ("mueva interruptor a V");
lcdPanel.print ("y conectar el celular);
Delay(2000);
}