#define pinAdc 4
unsigned int NilaiAdc;
float Tegangan;
void setup() {
// put your setup code here, to run once:
Serial.begin(115200);
}
void loop() {
// put your main code here, to run repeatedly:
NilaiAdc = analogRead(pinAdc);
Serial.println(NilaiAdc);
if (NilaiAdc==4095) {Tegangan = 3.3;}
if (NilaiAdc==0) {Tegangan = 0;}
Tegangan = NilaiAdc * (3.3/4095.0);
Serial.print("=");
Serial.println(Tegangan);
delay(1000); // this speeds up the simulation
}