追风筝的孩子 发表于 2014-12-5 17:37:22

ADC实验的时候error: 'A0' was not declared in this scope

error: 'A0' was not declared in this scope
怎么解决?

追风筝的孩子 发表于 2014-12-5 17:39:03

void setup()
{

Serial.begin(9600);         //使用9600速率进行串口通讯
}

void loop()
{

int n = analogRead(A0);    //读取A0口的电压值

float vol = n * (5.0 / 1023.0*100);   //使用浮点数存储温度数据,温度数据由电压值换算得到

Serial.println(vol);                   //串口输出温度数据
delay(2000);                           //等待2秒,控制刷新速度
}

Super169 发表于 2014-12-5 22:26:03

你用什麼 compile, 選了什麼板子, 不說清楚一點, 要大家猜謎嗎?
基本上, 如果只是想解決問題, 把 A0 改成 0 就可以了.

林定祥 发表于 2014-12-5 23:33:06

追风筝的孩子 发表于 2014-12-5 17:39 static/image/common/back.gif
void setup()
{



或者在setup()前定义下A0
页: [1]
查看完整版本: ADC实验的时候error: 'A0' was not declared in this scope