float currentvalue = 0.0f; // current display variable float AcsValue = 0.0f; // current reading variable /************************** * Start of Setup **************************/ void setup() { Serial.begin(9600); } /************************** * Start of Loop **************************/ void loop() { AcsValue = analogRead(A0); currentvalue = (2.5 - (AcsValue * (5.0 / 1024.0)) ) / 0.185; // 2.5 is the voltage of mean error so needs to be seperated. // AcsValue is the current sensor value. // 5/1024 are the number of steps. // 0.185 is the voltage change per 1 amperes. // currentvalue= meanvoltageerror - (sensorvalue * (voltage/resolution))/ voltage change per Ampere Serial.print("initialValue: "); Serial.print(AcsValue); Serial.print(mV); Serial.print(currentvalue*1000); Serial.print("mA"); delay(50); }