0
float result_temp = 0.0;
float original_temp = 0.0;
void setup() {
get_temp();
}
void loop() {
}
float get_temp()
{
for(int i = 0; i < 50; i++){
int analogValue = analogRead(2);
float temperature = (5.0 * 100.0 * analogValue)/1024;
result_temp += temperature;
original_temp = analogRead(pin_temp);
delay(100);
}
result_temp /= 50;
return result_temp;
}
我想運行它一次(在開始時)爲什麼它不工作?arduino:爲什麼我的功能沒有運行
什麼不起作用? –
您可能需要添加語言標記而不是元標記[tag:function]。 – Filburt
我懷疑你的代碼工作正常。你發佈的代碼使用'get_temp()'來檢索溫度,但是對它沒有任何影響。它不會通過串口發送它,或者有一些物理輸出做任何事情。 – mttrb