const int OneKilo = 327; // analogRead() value for a one kilogram test weight, determined experimentallyconst int TwoKilos = 561; // analogRead() value for a two kilogram test weight, determined experimentallyconst int countsPerKilo = TwoKilos - OneKilo; int grams(int analogValue) { analogValue -= (OneKilo - countsPerKilo); // Remove any offset from 0 weight = 0 volts return ((analogValue * 1000) / countsPerKilo); // Convert voltage to grams }

The possible downside is that it is integer and maybe you need decimal/floating point?