float resultado;
float tensao;
float whatsWatt(byte pin, float R1){
float P;
float U;
U = analogRead(pin);
tensao = U*5/1024;
P = (tensao*tensao/R1)*1000;
return P;
}
void setup() {
// put your setup code here, to run once:
Serial.begin(9600); // setup serial
}
void loop() {
// put your main code here, to run repeatedly:
resultado = whatsWatt(A0, 20000);
Serial.println(resultado);
delay(500); // faz 2 vezes por segundo
}