Pascalite 金物類/武器類: 気温 監視するing
HOME
- - - - - - - - - Other 構成要素 for programmers
- - - - - - - - - Pascalite, "How To Use It" main page
Pascalite 金物類/武器類: 気温 監視するing
気温 監視するing
The に引き続いて assumes you've got your Pascalite 始める,決める up and working. If it gives you what you want, 広大な/多数の/重要な. Be advised, however, that this page is subordinate to others. Visit my Pascalite, "How To Use It" main page if you (機の)カム drectly here and there are things "行方不明の".
(You can show numbers on the LCD if you have one, but the に引き続いて programs will also send at least part of every number to the four LEDs for those of you without an LCD 陳列する,発揮する.)
支配(する)/統制する 加える sell a nice little 気温 sensor for about $10. Like the LCD module, and RTC, it uses the I2C bus, so you can 監視する 気温 without giving up other inputs. You can only attach one sensor easily, but if you're up to some very fiddly soldering to a SMT 装置, you could have 8 気温 sensors. The I2C bus only 伴う/関わるs 4 wires, but there are 限界s to how long they can be. How long you can get away with, I don't know. The sensor reads 気温s to a 4半期/4分の1 of a Celcius degree, over a wide 範囲. (-55 -> +125 deg C).
The first program below will read the 気温 from the 装置 and 陳列する,発揮する it on the LCD... giving only the integer part of the 気温... truncated, not 一連の会議、交渉/完成するd, so a 気温 of 22.6 would appear as 22. It will also only work for 気温s above 無. (直す/買収する,八百長をするing those 制限s is the topic of the next program.) Even if you have no LCD, you should be able to see the program 答える/応じる to changes in the sensor's 気温 経由で the LEDs on d0, d1, d2, d3.
program IntTutTTure;
{For 肯定的な 気温s, without using the わずかの degree (警察などへの)密告,告訴(状)}
var bHi,bLo,bTmpG:byte;
手続き NumToLCD(bDisp:byte);
(as fro IntTut4)
end; {of 手続き}
begin
def_out(d0,d1,d2,d3);
令状(LCD,255); {(疑いを)晴らすs LCD}
repeat
令状(i2c,start);
令状(i2c,159);
延期する(80); {極小の 延期する: 80 ms}
read(i2c,bHi,bLo);
令状(i2c,stop);
NumToLCD(bHi);
bTmpG:=bHi Mod 10;{This line for people without LCD 陳列する,発揮するs}
bTmpG:=bTmpG+48;{This line for people without LCD 陳列する,発揮するs}
令状(portd,bTmpG);{This line for people without LCD 陳列する,発揮するs}
延期する(100);
until 4=5;
end.
Before we go 今後 and make better use of the 半導体素子, we're going to re-令状 the above using a 手続き to "終わりにする/要約する" the code which fetches a 気温 reading from the 半導体素子. (Features discussed in a moment...
program IntTutTTure2;
{For 肯定的な 気温s, without using the わずかの degree (警察などへの)密告,告訴(状)}
var bHi,bLo,bTmpG:byte;
手続き NumToLCD(bDisp:byte);
(as fro IntTut4)
end; {of 手続き}
手続き GetTture(var bGTHi,bGTlo:byte);
begin
令状(i2c,start);
令状(i2c,159);
延期する(80); {極小の 延期する: 80 ms}
read(i2c,bGTHi,bGTLo);
令状(i2c,stop);
end;
begin
def_out(d0,d1,d2,d3);
令状(LCD,255); {(疑いを)晴らすs LCD}
repeat
GetTTure(bHi,bLo);
NumToLCD(bHi);
bTmpG:=bHi Mod 10;{This line for people without LCD 陳列する,発揮するs}
bTmpG:=bTmpG+48;{This line for people without LCD 陳列する,発揮するs}
令状(portd,bTmpG);{This line for people without LCD 陳列する,発揮するs}
延期する(100);
until 4=5;
end.
In the last ("main") begin...end 封鎖する you will see a "new word for the language", GetTture, which we create by the "手続き GetTture(var bGTHi..." stuff. 公式文書,認める those three little letters "var" in the procdure header. The 影響 of them is to send 支援する whatever is in bGTHi and bGTLo when the 手続き finished 遂行する/発効させるing. If we called it with GetTture(foo,妨げる/法廷,弁護士業), then what was in bGTHi will appear in foo, and what was in bGTlo will be in 妨げる/法廷,弁護士業.
I should thank 広告 Verheijen at 支配(する)/統制する 加える for a 見本 program which reminded me of how nicely things can be done if you use var. Thank you, 広告! Moving on....
=====
The 装置 reads 気温s to 0.25 degree Celcius. If the 気温 is above 無, then the two most 重要な bits of bLo tells you about the 4半期/4分の1 degrees. We'll talk about 消極的な 気温s in a moment.
Thus, as long as 気温s remain 肯定的な, you could have....
gotoxy(3,0){assuming degrees 陳列する,発揮するd in the first three character positions of the first line}
if (bLo and 192)=192 then then 令状(LCD,".75 degrees C");
if (bLo and 192)=128 then then 令状(LCD,".50 degrees C");
if (bLo and 192)= 64 then then 令状(LCD,".25 degrees C");
if bLo<64 then 令状(LCD,".00 degrees C");
Now.. to を取り引きする 消極的な 気温s, we need to look more closely at the messages sent to us by the 気温 sensor.
First of all, I'm going to 令状 things in binary for a while, so if I want to show five I'll 令状 0000 0101. The 主要な 無s are nothing special, even if we don't often use them in everyday numbers. The space is just to help you keep 跡をつける of where you are in the number. (It's like the commas in "one million, two hundred thousand...." when writeen "1,242,152")
I'm going to show all of the bits (1s or 0s) of bHi, but only the first (most 重要な) bit of bLo, and the one after that.
If the 気温 is +5 degrees, bHi + the first two bits of bLow will be: 0000 0101 00
More examples:
気温 / bHi + the first bit of bLow
+5.5 0000 0101 10
0 0000 0000 00
-0.5 1111 1111 11
-25 1110 0111 00
-55 1100 1001 00
+25 0001 1001 00
They're just using twos complement, with the LSB 価値(がある) 0.25. You knew that! (And if you didn't....)
program IntTutTTur3;
{見解/翻訳/版: 17 損なう 03}
{By: TK Boyd, http://sheepdogsoftware.co.uk
陳列する,発揮するs 消極的な and 肯定的な ttures, and 4半期/4分の1 degrees
Analog 装置s sensor number 7416 returns the 気温
as a 10 bit twos complement number. The most 重要な 8 bits are
returned to bHi MSB in bHi(7) in the に引き続いて, the LSB in bit 6
of bLo, and the remaining bit in bLo(7)}
var bHi,bLo,bTmpG:byte;
手続き NumToLCD(bTmp:byte);
var bTens,bTmp2:byte;
begin
gotoxy(1,0);{It appears that the parameters of GOTOXY cannot be variables.}
令状(LCD," ");{6 spaces}
gotoxy(1,0);
if bTmp>199 then begin
令状(LCD,"2");
bTmp:=bTmp-200;
end {was>199} else
if bTmp>99 then begin
令状(LCD,"1");
bTmp:=bTmp-100;
end {was >99} else 令状(LCD," ");
{100's digit now done}
if bTmp>9 then begin
bTens:=bTmp DIV 10;
bTmp2:=bTens*10;
bTmp:=bTmp-bTmp2;
bTens:=bTens+48;
令状(LCD,bTens);
end else 令状(LCD," ");
{10's digit now done}
bTmp:=bTmp+48;
令状(LCD,bTmp);{And finally: 令状 部隊s digit}
end; {of 手続き}
手続き GetTture(var bGTHi,bGTlo:byte);
begin
令状(i2c,start);
令状(i2c,159);
延期する(80); {極小の 延期する: 80 ms}
read(i2c,bGTHi,bGTLo);
令状(i2c,stop);
end;
begin
令状(LCD,255); {(疑いを)晴らすs LCD}
settime(0,0,0,0);
repeat
GetTture(bHi,bLo);
{Here begins code to 解釈する/通訳する bHi, bLo as
10 bit 2s complement...
If the number is 肯定的な, the contents of bHi
and bLo arrive at the "令状" 声明s 不変の.
If the number is 消極的な, the contents of bHi and
bLo are 一致した to the 肯定的な 同等(の). E.g.,
if the 気温 is -12.25, then by the time the
"令状" 声明 is reached, bHi 持つ/拘留するs 12, and bLo
持つ/拘留するs just what was in the 2 MS bits of bLo. (e.g.
10xx xxxx will have become 0000 0010}
gotoxy(0,0);
令状(LCD,"+");{provisionally}
bLo:=bLo DIV 64; {転換 最高の,を越す two bits to 権利-手渡す end}
if bHi>127 then begin {number is 消極的な}
gotoxy(0,0);
令状(LCD,"-");
bHi:=bHi XOR 255; {complement}
bTmpG:=bLo;
{に引き続いて 天然のまま... but 作品! (I hope!)}
bLo:=0;{to 避ける begin..end with first if below}
if bTmpG=0 then inc(bHi);{bLo can stay 無}
if bTmpG=1 then bLo:=3;{no need to inc(bHi)}
if bTmpG=2 then bLo:=2;{no need to inc(bHi)}
if bTmpG=3 then bLo:=1;{no need to inc(bHi)}
end;
NumToLCD(bHi);
if bLo=0 then 令状(LCD,".00 degrees C");
if bLo=1 then 令状(LCD,".25 degrees C");
if bLo=2 then 令状(LCD,".50 degrees C");
if bLo=3 then 令状(LCD,".75 degrees C");
if bLo>3 then 令状(LCD,"ERROR IN TTure CODE!");
延期する(100);
until 4=5;
end.
To search THIS 場所/位置.... (Go to the 場所/位置's above, and use their search buttons if you want to seach them.)...
Way to search this 場所/位置 without using forms
広告 from page's editor: Yes.. I do enjoy
収集するing these things for you... hope they are helpful. However..
this doesn't 支払う/賃金 my 法案s!!! If you find this stuff useful, (and you
run an MS-DOS or Windows pc) please visit my freeware and shareware
page, download something, and 循環させる it for me? Links on your page
to this page would also be 高く評価する/(相場などが)上がるd!
Click here
to visit editor's freeware, shareware page.
Link to editor's (Arunet) homepage
How to email or 令状 this page's editor, Tom Boyd