Arduinoと出会ってから何度も挑戦しているサーミスタで作るArduinoの温度計ですが、とりあえずLCD表示だけですが、完成したんじゃないかなぁ。
これから、あるもの(?)を動かすために出力の方に手をかけなければならないのですが・・・
気温
↓
サーミスタ
↓
抵抗値
↓
電圧値
↓
アナログイン0
↓
計算(サーミスタの計算には対数計算が必要なのですが、Arduinoではできなさそうなのでパソコンでテーブルを作成し、配列で持っています)
↓
温度値
という作業を経てLCDに表示しています。
------------------------------------------------------------------
#include <LiquidCrystal.h>
LiquidCrystal lcd(12,11,5,4,3,2);
//サンプリング値に対応した温度×10
int temp[] = {0,-869,-797,-751,-718,-691,-669,-649,-632,-617,-603,-590,-578,-567,-557,-547,-538,-529,-521,-513,-506,-499,-492,-485,-479,-472,-466,-461,-455,-450,-444,-439,-434,-429,-424,-420,-415,-411,-406,-402,-398,-394,-390,-386,-382,-378,-375,-371,-367,-364,-360,-357,-354,-350,-347,-344,-341,-338,-335,-332,-329,-326,-323,-320,-317,-314,-311,-309,-306,-303,-301,-298,-295,-293,-290,-288,-285,-283,-280,-278,-276,-273,-271,-268,-266,-264,-262,-259,-257,-255,-253,-251,-248,-246,-244,-242,-240,-238,-236,-234,-232,-230,-228,-226,-224,-222,-220,-218,-216,-214,-212,-211,-209,-207,-205,-203,-201,-199,-198,-196,-194,-192,-191,-189,-187,-185,-184,-182,-180,-179,-177,-175,-174,-172,-170,-169,-167,-165,-164,-162,-161,-159,-157,-156,-154,-153,-151,-150,-148,-147,-145,-144,-142,-141,-139,-138,-136,-135,-133,-132,-130,-129,-127,-126,-124,-123,-122,-120,-119,-117,-116,-114,-113,-112,-110,-109,-108,-106,-105,-103,-102,-101,-99,-98,-97,-95,-94,-93,-91,-90,-89,-87,-86,-85,-84,-82,-81,-80,-78,-77,-76,-75,-73,-72,-71,-69,-68,-67,-66,-64,-63,-62,-61,-60,-58,-57,-56,-55,-53,-52,-51,-50,-49,-47,-46,-45,-44,-43,-41,-40,-39,-38,-37,-35,-34,-33,-32,-31,-30,-28,-27,-26,-25,-24,-23,-22,-20,-19,-18,-17,-16,-15,-14,-12,-11,-10,-9,-8,-7,-6,-5,-3,-2,-1,0,0,1,2,3,4,5,7,8,9,10,11,12,13,14,15,16,17,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100,101,102,103,104,105,106,107,108,109,110,111,112,113,114,115,116,117,118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,134,135,136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,150,151,152,153,154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,170,171,172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,188,189,190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,206,207,208,209,210,211,212,212,213,214,215,216,217,218,219,220,221,222,223,224,225,226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,242,243,244,245,246,247,248,250,251,252,253,254,255,256,257,258,259,260,261,262,263,264,265,266,267,268,269,270,271,272,273,274,275,276,277,278,279,280,281,282,283,284,285,286,287,288,290,291,292,293,294,295,296,297,298,299,300,301,302,303,304,305,306,307,309,310,311,312,313,314,315,316,317,318,319,320,321,322,324,325,326,327,328,329,330,331,332,333,334,336,337,338,339,340,341,342,343,344,345,347,348,349,350,351,352,353,354,356,357,358,359,360,361,362,363,365,366,367,368,369,370,372,373,374,375,376,377,378,380,381,382,383,384,385,387,388,389,390,391,393,394,395,396,397,399,400,401,402,403,405,406,407,408,409,411,412,413,414,416,417,418,419,421,422,423,424,426,427,428,429,431,432,433,434,436,437,438,440,441,442,443,445,446,447,449,450,451,453,454,455,456,458,459,460,462,463,464,466,467,469,470,471,473,474,475,477,478,479,481,482,484,485,486,488,489,491,492,494,495,496,498,499,501,502,504,505,506,508,509,511,512,514,515,517,518,520,521,523,524,526,527,529,530,532,533,535,537,538,540,541,543,544,546,548,549,551,552,554,556,557,559,560,562,564,565,567,569,570,572,574,575,577,579,581,582,584,586,587,589,591,593,594,596,598,600,602,603,605,607,609,611,612,614,616,618,620,622,624,625,627,629,631,633,635,637,639,641,643,645,647,649,651,653,655,657,659,661,663,665,667,669,671,674,676,678,680,682,684,686,689,691,693,695,698,700,702,704,707,709,711,714,716,718,721,723,726,728,730,733,735,738,740,743,745,748,750,753,756,758,761,763,766,769,771,774,777,780,782,785,788,791,794,797,799,802,805,808,811,814,817,820,823,826,830,833,836,839,842,846,849,852,855,859,862,866,869,873,876,880,883,887,890,894,898,902,905,909,913,917,921,925,929,933,937,941,945,950,954,958,963,967,971,976,981,985,990,995,999,1004,1009,1014,1019,1024,1030,1035,1040,1046,1051,1057,1062,1068,1074,1080,1086,1092,1098,1104,1111,1117,1124,1130,1137,1144,1151,1158,1166,1173,1181,1188,1196,1204,1213,1221,1229,1238,1247,1256,1265,1275,1285,1295,1305,1316,1326,1337,1349,1360,1372,1385,1397,1411,1424,1438,1452,1467,1483,1499,1516,1533,1551,1569,1589,1609,1631,1653,1677,1702,1728,1755,1785,1816,1849,1885,1924,1966,2011,2061,2115,2176,2245,2323,2413,2518,2646,2805,3012,3304,3768,4751};
int val = 0;
void setup(){
lcd.begin(16, 2);
}
void loop() {
val = analogRead(0);
lcd.clear();
lcd.print( val ); //サンプリング値
lcd.write( 0x3d); // = イコール
lcd.print( temp[val] / 10); // 整数
lcd.write( 0x2e); // . カンマ
lcd.print( temp[val] % 10); // 小数点以下
delay(1000);
}