const int OneKilo = 327; // analogRead() value for a one kilogram test weight, determined experimentally
const int TwoKilos = 561; // analogRead() value for a two kilogram test weight, determined experimentally
const 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
}