int const sensorPin=39;
int sensorValue=0;
double voltaje= 0.0;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
sensorValue=analogRead(sensorPin);
voltaje=scale(sensorValue,0.0,4095,0.0,3.3);
Serial.println(voltaje);
delay(10); // this speeds up the simulation
}
double scale(double x, double in_min, double in_max, double out_min, double out_max) {
return (x - in_min) * (out_max - out_min) / (in_max - in_min) + out_min;
}