定义了一个二维数组,但是后面输出的temp_Value不变且都为0,求高手帮忙改一下程序
#include <avr/pgmspace.h>
int Digital_Value=0;
float Voltage_Value=0;
float Rt_Value=0;
float temp_Value=0;
float a=0;
float b=0;
const float RP[70][2] PROGMEM ={-20,80.59,-19,76.32,-18,72.31,-16,64.99,-15,61.65,-14,58.51,-13,55.55,-12,52.76,-11,50.13,-10,47.65,-9,45.31,-8,43.10,-7,39.05,-6,37.19,-5,35.43,-4,41.02,-3,33.76,-2,32.19,-1,30.69,0,29.28,1,27.95,2,26.68,3,25.48,4,24.34,5,23.26,6,22.23,7,21.26,8,20.34,9,10,19.46,11,18.62,12,17.83,13,17.08,14,16.36,15,15.68,16,15.03,17,14.41,18,13.82,19,13.26,20,12.73,21,12.22,22,11.73,23,11.27,24,10.83,25,10.40,26,10.00,27,9.62,28,9.25,29,8.90,30,8.57,31,8.24,32,7.93,33,7.64,34,7.36,35,7.09,36,6.83,37,38,6.59,39,6.35,41,5.90,42, 5.70,43,5.50,44,5.31,45,48,4.62,49,4.46,50,4.31,65,2.49,69,2.21,115,0.66,119,0.60};
void setup(){
Serial.begin(9600); //波特率设置为9600
}
void loop(){
Digital_Value =analogRead(2); //读取电压值(数字量)
Serial.println(Digital_Value,2);
Voltage_Value=(3.3* Digital_Value)/1023;
Serial.println(Voltage_Value,2);
Rt_Value=10*Voltage_Value/(3.3-Voltage_Value);
Serial.println(Rt_Value,2);
for(int i=0;i<75;i++)
{
a=pgm_read_byte_near(RP[0][i]);
b=pgm_read_byte_near(RP[0][i]);
if((a<=Rt_Value)&&(Rt_Value<b))
temp_Value=pgm_read_byte_near(RP[i][0]);
break;}
Serial.print("temperature is: ");
Serial.print(temp_Value,2); //发送温度数据
Serial.println(" C");
delay(2000); //一秒刷新一次
}
|