http://arduino.cc/en/Reference/Board
In addition to the specific functions listed below, the analog input pins support 10-bit analog-to-digital conversion (ADC) using the analogRead() function.
貌似arduino已经集成了ADC的功能了..
analogReference(INTERNAL);//set the volt to 1.1v
int i = 0, count = 5, val = 0;
delay(500);
for(i=0;i<count;i++)
{
int v =analogRead(potPin);// 读取传感器的模拟值并赋值给val
Serial.println(v);
val+=v;
delay(100);
}
val = val/count;
//dat=(125*val)>>8;//温度计算公式
dat = val*0.48828125*1.1/5;
delay(100);
Serial.println(dat);//输出显示dat 的值
delay(500);//延时0.5 秒