s930427 发表于 2016-9-8 13:13:17

Arduino Analog輸入有誤差

現在用A10 讀一個 0V~5V的值,
但是會有很大的誤差值!!怎麼會這樣呢?

輸入1V時,應該要是204.8 ,但是會跳出198 ~219
請問這樣是正常的誤差值嗎?


void setup() {
// put your setup code here, to run once:
Serial.begin(38400);
pinMode(A10, INPUT);
}

void loop() {
// put your main code here, to run repeatedly:
int n1 = 0;
int n2;
delay(2000);
for(int i = 0; i < 10; i++)
{
    n2 = analogRead(A10);
    delay(5);
    n1 += n2;
}
Serial.println(n1/10);
}

弘毅 发表于 2016-9-8 13:34:18

需要准确的基准源

s930427 发表于 2016-9-8 13:41:56

弘毅 发表于 2016-9-8 13:34
需要准确的基准源

您好,
準確的基準源?
直接接GND不是嗎?
還是說程式上的問題?

弘毅 发表于 2016-9-8 13:44:07

s930427 发表于 2016-9-8 13:41
您好,
準確的基準源?
直接接GND不是嗎?


你以USB口供电,USB电压不一定是5V,4.7-5.2范围都是可能的。而且USB电压波纹太大。。。如果你板子器件用的好,可以使用3V3作为外部基准源。我们教程中有帖子。。。。

弘毅 发表于 2016-9-8 13:45:14

http://www.geek-workshop.com/forum.php?mod=viewthread&tid=5717&page=1&extra=#pid41947
页: [1]
查看完整版本: Arduino Analog輸入有誤差