You are reading a single comment by @Gordon and its replies. Click here to read the full conversation.
  • Your best bet is to take many measurements, and to then take the average of those. For instance:

    var sum = 0;
    var n = 100;
    for (var i=0;i<n;i++) sum+=analogRead(INPUT_PIN);
    var result = sum/n;
    

    There are other ways you can do this as well, for instance you can median filter:

    var arr = new Uint8Array(100);
    for (var i=0;i<arr.length;i++) arr[i]=analogRead(INPUT_PIN);
    arr.sort();
    result  = arr[arr.length/2];
    
About

Avatar for Gordon @Gordon started