When applying steady voltage in the range of 3.3V to the analog pin I get no steady readings in the digital converted value.
The Netduino is a revB board and the AREF is also coubled to the 3.3V internal supply on the board.
The code attached
private int read_a(AnalogInput readport) { int avg = 10; int[] a_data = new int[avg]; int average = 0; string readresult = ""; for (int i = 0; i < avg; i++) { a_data[i] = readport.Read(); average += a_data[i]/avg; readresult += a_data[i].ToString() + " " ; } Debug.Print(readresult); return average; }
I think this is wrong because of these values:
476 473 474 474 477 473 476 475 475 476
bat1_a 470
when it should return 474.9 or 475 if you prefer.
So try this:
private int read_a(AnalogInput readport) { int nums = 10; int total = 0; double average; string readresult = ""; for (int i = 0; i < nums; i++) { int temp = readport.Read(); total += temp; readresult += temp + " " ; } average = temp / nums; Debug.Print(readresult); return (int)average; }if you want to round up then do: return (int)(average + 0.5);
Let me know if those averages are accurate then.
Sorry I had to leave you this morning, I had to get to the airport.