|
このページはEtoJ逐語翻訳フィルタによって翻訳生成されました。 |
This tutorial shows you how to 接近 two or more Dallas 1-Wire 数字表示式の 気温 sensors, DS18B20s. Don't be 脅すd by the "DS"... yes, this is a 半導体素子 from Dallas's 1-wire family , but you don't have to を取り引きする some of the fancier 適切な時期s 申し込む/申し出d by the 1-Wire 半導体素子s. You don't need the general Arduino 1-Wire library.
This is a 爆撃する, ーするつもりであるd for 拡大.
It reads a number of 気温 (tture) sensors. And 現在のs the values on the serial 監視する.
But you wouldn't go to all this trouble just to read some sensors. You'd want to do something with those readings.
The place you 追加する your code is 示すd in what is 現在のd here.
(If you just want to 逮捕(する) the tture readings, an SD card makes a 広大な/多数の/重要な choice, and 記録,記録的な/記録するing what would さもなければ go to the serial 監視する is very 平易な if you spend a LITTLE money ($20), and very, very 平易な, and cheap ($5), with just a LITTLE work!)
I'm exceedingly 感謝する to the 肉親,親類d readers who send suggestions for this page. Not just 示唆するs... 完全にする Arduino .ino とじ込み/提出するs!
As I did with the June 2019 見解/翻訳/版, I am giving you a download link for ジーンズ-Luc's take on this code. I believe he lives in フラン.
I 港/避難所't 診察するd the code in 詳細(に述べる)... yet!... but if someone has the wits to send it, I think his work may 井戸/弁護士席 be 価値(がある) considering, don't you.
English is not his first language, as you will see, But I for one won't look the gift horse in the mouth. Here is what he had to say about his 見解/翻訳/版 of the code. There are also useful comments embedded in the code... a very good place for them!
I had to adapted it for use it really with a DS18B20. It was significavely wrong for 消極的な 気温. I 回復する for just 1 wire, but it can really simple to make an array for different wires. Sorry, my comments are in French, and i have no time to translate anyway. You can 抑える them... This soft take no 全世界の RAM. :-) It 行方不明になる bus and CRC, but for me it's ok.
I think he meant...
I have 改訂するd the 初めの code at (the page you
are reading) so it 作品 適切に with a DS18B20.
The 初めの code (as I think I said?) gave WRONG
readings for for 消極的な 気温.
The 見解/翻訳/版 I've 供給する is for reading just one sensor,
but it has been written to make it 平易な to read from
several sensors, each on a different I/O line.
This 見解/翻訳/版 of the code uses no 全世界の RAM. :-)
("has no 全世界の variables"?)
(I can't guess what "It 行方不明になる bus" meant. Perhaps he
meant it couldn't 接近 多重の sensors on a
Microlan? (My code didn't do that either. Nor did it do...
And it doesn't use the checksum to 実証する the data.
(Another thing the 初めの code didn't do, as I 解任する.)
Enjoy! 価値(がある) what it cost you!
The same 肉親,親類d reader について言及するd below sent some MORE code, 6/19. (If you find it useful... "支払う/賃金 it 今後", support the Australian charity of 肉親,親類d Reader's choice: Very Special Kids, if you want to show 評価 for the reader's 親切 to us all. (On its website, Very Special Kids says that its 使節団 is to support families of children with life-脅すing 条件s.))
This page is becoming a mish-mash... 陳謝s! But I can at least give you a way to download the 6/19 見解/翻訳/版 of the code. It uses one pin per 気温 sensor. (I've 簡単に put the .ino とじ込み/提出する online. Let me know if you have trouble downloading. As is usual for the Arduino IDE, you'll have to put it ("ar3ne1tt2-MultTture19609.ino") in a folder 指名するd "ar3ne1tt2-MultTture19609". You can, of course, 割り当てる your own 指名する... but folder and .ino must agree.
A helpful letter from a reader showed me places where this is wrong.
I believe the code that was here until 22 Feb 19 "worked"... I don't put things on the web without trying them (unless explicitly flagged as "off the 最高の,を越す of my 長,率いる")... but...
But the code shouldn't have worked! There were problems in how some タイミング 問題/発行するs that need 支払う/賃金ing attention to when using the Dallas DS18xx 気温 sensing 半導体素子s were 存在 dealt with!
Also, even if it 作品, for it to be USEFUL, you need to know some things. (And it could still be written better. A 使用者 won't see different 行為, but the code will be written better... and 達成する the same result in a different way. "Written better" is IMPORTANT, even when there are no 機能の changes.)
When you work with the Dallas 半導体素子s, it goes like this:
Sigh. Sorry.
(By the way: Dallas calls the first part of "take reading" part as "doing a 転換"... the 気温 around the sensor is "変えるd" into some numbers inside the sensor.)
The flow of the program as it was didn't need a 完全にする rethink, but it did need some re-working.
The code does 収集する... but has not had その上の 実験(する)ing.. I have not 麻薬中毒の an Arduino with that code up to some 半導体素子s, seen reading 注ぐ 前へ/外へ. But, "it should work". I hope that will be your experience, 特に after I failed you and 以前 published BAD code... which did, I'm sure, "work". I just can't see how.
If you feel you want to 緩和する into this 支配する more gently, I have a "How to connect one DS18B20 to an Arduino" essay for you.
There's also my more general introduction, an overview of using 1-Wire 半導体素子s
In the "解答" on this page, we are taking the "simple/ expensive" 大勝する: We will be using a separate data line for each of the sensors we want to read. To put that a different way: We won't be using the 力/強力にする of the 1-Wire 半導体素子s to co-存在する on a little "網状組織" of their own. (Such 網状組織s are called "MicroLans" (a trademarked 称する,呼ぶ/期間/用語, which is helpful for Google searching!)
Know this: The program has to run for a bit (about 10 seconds) before you will have "good numbers" for five sensors. This is 予定 to something in the nature of the Dallas 気温 sensing 半導体素子s that I will try to explain soon.
Those 半導体素子s are 価値(がある) the trouble, by the way!
The "answers", i.e. the readings from the sensors, will be in the elements of TReading. The first sensor reading is in TReading[0]. (They're also in other places, which we will come to in a moment.)
There's a "trick" you need to know about: If the sensor was exposed to, say, 12.7 degrees C, then in TReading[x] you will find 127. The 気温s are 蓄える/店d in tenths of Centigrade degree. (This 避けるs the hassle of 取引,協定ing with floating point numbers.)
Ummm. Unless they are 蓄える/店d in CENTI degrees. TReading[x] might be 持つ/拘留するing 1274 to 代表する 12.74 degrees C. I'm a little 混乱させるd on that point at the moment... and there may be 欠陥s in the code, as a result. Let me know what you see, if you find the time and energy to bring this code to some 金物類/武器類!
The "other places"... besides having nice simple integers in TReading[x], the ttures, in nice everyday ordinary degrees C, along with their 汚い わずかの parts, are in fT_c100[x].
And, to make printing the values 平易な, the integer part is in Whole[x] and the part to the 権利 of the decimal point is, as an integer, in Fract[x]. (To go with Whole and Frac, there's something in SignBit[2] to say if the 連合させるd Whole+Frac 肯定的な degrees, or 消極的な degrees. (I think the "something" will be a 0 or a 1, with 0 meaning the 気温 was below 無. It will be something like that. Maybe the other way around.)
Other variables
There are some "trivial" arrays which may be useful to you, 特に in 現在のing the data...
If sensor "2" returned 12.7 degrees C, then TReading[2] has 127 in it. 罰金. That's going to be "the best" place to look for most things. But also, you'll have 12 in Whole[2], 7 in Fract[2], and something in SignBit[2] to say if that's 肯定的な 12.7 degrees, or 消極的な 12.7 degrees. (I think the "something" will be a 0 or a 1, with 0 meaning the 気温 was below 無. It will be something like that. Maybe the other way around.) (Whole[] will 持つ/拘留する the 絶対の value of the tture, be it +ve or -ve.)
It might not look like it, but "all" you need to understand of the code さらに先に 負かす/撃墜する the page is....
無効の 宙返り飛行(){
digitalWrite(13,!digitalRead(13));//To Pulse LED, to show prgm is running
readTturePt1(tture[bWhichSensor]);//N.B.: Values passed 支援する in 全世界のs
延期する(1900);//This is "wait for 転換" (see webpage)
readTturePt2(tture[bWhichSensor]);//N.B.: Values passed 支援する in 全世界のs
延期する(50);
printTture();//N.B.: Takes values from 全世界のs.
Serial.print(" ");
if(bWhichSensor == 0){
Serial.print("\n");//Start new line
}
bWhichSensor++;
if(bWhichSensor == kTtureSensorMaxIndex+1){
bWhichSensor = 0;
}
/*"YOUR STUFF GOES HERE... if, for instance, you
making a 解雇する/砲火/射撃 alarm system, this is where you
put "if tture is too high, (犯罪の)一味 alarm bell".
-------------------
If you take steps to 確実にする that at least 1.9
seconds pass between the calls of...
readTturePt1
... and...
readTturePt2
... then, as long as you leave the pin associated
with the sensor alone, you can "do things"
during the time the system is waiting for the
転換 to 完全にする.
*/
}//end of 宙返り飛行()
Okay... the above and a few extra 詳細(に述べる)s is all you need to understand. We'll come 支援する to the above in a moment. The 詳細(に述べる)s are....
At the 長,率いる of the code (after 使用者's needs tweakings), we have:
const byte kTtureSensorMaxIndex=4;//Make this 4 if you
//want to use 5 sensors
//CARE This next one is a little tricky...
//If kTtureSensorMaxIndex = 4, then you need FIVE
// numbers in the に引き続いて array. They will
// define which pins the 気温 sensing
// 半導体素子s should go on.
//The number of numbers in the { }s must be
// 正確に/まさに kTtureSensorMaxIndex+1
// (Arrays are 無 based.)
//The に引き続いて...
// const byte kTtureSensorMaxIndex=2;
// int tture[kTtureSensorMaxIndex] = {3,4,5};
//Would 始める,決める the program up to を取り引きする three
// 気温 sensors. They would have to be
// on the pins for the GPIO lines 3, 4 and 5.
//kTtureSensorMaxIndex is 始める,決める a little higher up
// the page.
int tture[kTtureSensorMaxIndex+1] = {3,4,5,6,7};
//In the 宣言, the number in [] is the COUNT
// of array elements... not the 索引 of the last.
//(The 索引 of the last will be one いっそう少なく than the
// count, as the first element of the array is
// tture[0], by "指名する".
This tells the program which pins of the Arduino will be connected to the 気温 sensors.
----
Then there's....
int TReading[kTtureSensorMaxIndex], SignBit[kTtureSensorMaxIndex],
Whole[kTtureSensorMaxIndex],Fract[kTtureSensorMaxIndex];
float fTc_100[kTtureSensorMaxIndex];
... to create places to put the answers. (No ロケット/急騰する science there.)
----
And in the 体制/機構() 機能(する)/行事:
for (bLoopCounter = 0;
bLoopCounter <= kTtureSensorMaxIndex;
bLoopCounter++)
{
pinMode(tture[bLoopCounter], INPUT);
digitalWrite(tture[bLoopCounter], LOW);//無能にする 内部の pull-up.
}
Again... These are just 決まりきった仕事 configuration 命令(する)s. 令状ing to an input might seem strange. We are making sure that the 内部の pull-up resistor which could be on the input is not connected, this time.
Everything else in the code is either basic, basic, general stuff, or "黒人/ボイコット box" stuff that you put in and leave alone, as is.
I've done a Bad Thing ーするために keep the code simple. I've used 全世界の variables: HighByte, LowByte, etc.
A 特に "bad" 全世界の variable is "bWhichSensor".
The way the program 作品 is that it reads each 気温 sensor in turn. And "bWhichSensor" keeps 跡をつける of which sensor's turn it is.
It starts of at 無, 予定 the way it was 宣言するd.
It goes 0, 1, 2, 3, 4, 0, 1, 2, 3, 4, 0, 1,...
... because of the bit of code at the 底(に届く) of 宙返り飛行().
The 命令(する) "readTturePt1(xx)" tells the Arduino to go off and do the first step for checking one of the sensors. (Which sensor is checked is 決定するd by what "xx" is.)
Then we must wait. (That's the way the 1-Wire 半導体素子s work.)
Then, with "readTturePt2(xx)", we collect the raw numbers that the sensor now has ready for us, and put the 関連した data into the さまざまな 全世界の variables 関心d.
Then you can "printTture(xx)" to get the just fetched 気温 陳列する,発揮するd 経由で the serial 監視する.
That use of 全世界の variables is "poor programming"... but it 作品. It is a Bad Idea because it is 平易な for bugs to creep in and hide in such opaque programming. But The 権利 Way To Do It 要求するs that you understand a コンビナート/複合体 data type, and I want this essay accessible to many readers.
詳細(に述べる)s of how to connect the sensor... really 平易な... and 詳細(に述べる)s of what goes on inside the "黒人/ボイコット box" parts of the program are covered in 詳細(に述べる) in my page about reading just one DS18B20.
Here is the code for reading five DS18B20's on an Arduino. (The number of sensors you can read is easily changed... just change the value in kTtureSensorMaxIndex.
New 見解/翻訳/版, 23 Feb 19. The に引き続いて HAS NOT BEEN TESTED, but it DOES COMPILE. I think it "should" work, and would commend it to you.
/*ReadDS18B20mk19222*/
const String sPrgmName="ReadDS18B20mk19222";
const String sVers="23 Feb 19";
/*See...
https://sheepdogguides.com/arduino/ar3ne1tt2.htm
... for explanation of this code.
The approach taken here is straightforward, but inefficient.
A serious problem arose 23 Feb 19 in working on this code
in the Arduino compiler at a time when I couldn't do more
that see if it 収集するs without (民事の)告訴.
The problem was that parts of what I had 示唆するd that
this returns the 気温 readings (tture) (in the
elements of the array "TReading" in TENTHS of degree C...
and other parts said the values were in HUNDREDTHS of degree C
There are その上の 公式文書,認めるs about this in the 関連した place.
-------------------------------------------------------------
Started life as code adapted from nuelectronics.com デモ
-------------------------------------------------------------
If for what you are doing, you need a more responsive system,
change the programming わずかに...
Send a "start 転換" to ALL of the sensors,
one after the other. (Call readTturePt1 to send that)
Wait 1.9 seconds.
Read the ttures discovered, from ALL of the sensors,
one after the other. (Call readTturePt2 to send that)
====================
OLD REMS---vers: 6 Jly 14- 修正するd by Brian (twice!) for 5 sensors,
better responsiveness. Derived from vers 18 July 2010
Started end of 称する,呼ぶ/期間/用語 eve WG/TA/LE/EW/JGB
*/
const byte pLED=13;//始める,決める this to the line on which
//you will have an LED, tied to ground, through
//a resistor. (Such a resistor is 利用できる on the
//board for many Arduinos.)
const byte kTtureSensorMaxIndex=4;//Make this 4 if you
//want to use 5 sensors
//CARE This next one is a little tricky...
//If kTtureSensorMaxIndex = 4, then you need FIVE
// numbers in the に引き続いて array. They will
// define which pins the 気温 sensing
// 半導体素子s should go on.
//The number of numbers in the { }s must be
// 正確に/まさに kTtureSensorMaxIndex+1
// (Arrays are 無 based.)
//The に引き続いて...
// const byte kTtureSensorMaxIndex=2;
// int tture[kTtureSensorMaxIndex] = {3,4,5};
//Would 始める,決める the program up to を取り引きする three
// 気温 sensors. They would have to be
// on the pins for the GPIO lines 3, 4 and 5.
//kTtureSensorMaxIndex is 始める,決める a little higher up
// the page.
int tture[kTtureSensorMaxIndex+1] = {3,4,5,6,7};
//In the 宣言, the number in [] is the COUNT
// of array elements... not the 索引 of the last.
//(The 索引 of the last will be one いっそう少なく than the
// count, as the first element of the array is
// tture[0], by "指名する".
byte bLoopCounter = 0;//used for misc 宙返り飛行 反対するs.
//Values in bLoopCounter do not need to 固執する
// in places not nearby where it is 始める,決める.
//In older 見解/翻訳/版s of this code, "x" was used
// as bLoopCounter is now used.
//It was made 全世界の only because having a
// variable for this sort of 仕事 is often useful.
byte bWhichSensor = 0;//This variable was called "count"
//in earlier 見解/翻訳/版s of this code.
//に引き続いて 全世界のs used to communicate results 支援する
//from readTturePt1, Pt2, and to send data to printTture...
//See webpage for what they 持つ/拘留する.
int TReading[kTtureSensorMaxIndex], SignBit[kTtureSensorMaxIndex],
Whole[kTtureSensorMaxIndex],Fract[kTtureSensorMaxIndex];
//Whole[] 持つ/拘留するs the ABSOLUTE VALUE of the integer part
// of the reading. E.g. for either 12.7 r -12.7, Whole
// 持つ/拘留するs 12. (SignBit[] tells you if it is +ve or -ve.)
float fTc_100[kTtureSensorMaxIndex];
//----------------------------------------------------------
無効の 体制/機構() {
//For each tture sensor: Do a pinMode and a digitalWrite
for (bLoopCounter = 0;
bLoopCounter <= kTtureSensorMaxIndex;
bLoopCounter++)
{
pinMode(tture[bLoopCounter], INPUT);
digitalWrite(tture[bLoopCounter], LOW);//無能にする 内部の pull-up.
}
pinMode(pLED,OUTPUT);//Just so it can "pulse" to show Arduino
// is working
Serial.begin(9600);
延期する(300);//Wait for newly 再開するd system to 安定させる
Serial.println(sPrgmName);
Serial.println(sVers);
Serial.println();
Serial.println("See https://sheepdogguides.com/arduino/ar3ne1tt2.htm");
Serial.println("気温 測定, 多重の Dallas DSxxxx sensors");
Serial.println("The 'S' value at the start of each line identifies the sensor reading was from.");
Serial.println();
}//end of 体制/機構()
/*=========================================
The 宙返り飛行() subroutine:
It 完全にするs in just under 2 seconds.
Each pass fully reads one sensor, and 追加するs a line
to the serial 監視する 陳列する,発揮する.
The first pass 過程s sensor 0, the next
sensor 1, and so on to sensor kTtureSensorMaxIndex.
After that, the next pass goes 支援する, reads sensor0
again. And thus the big cycle proceeds.
There is at least a second's "dead time" which,
with careful coding, could be used for other
things.
Even without clever coding, this is the place
*/
無効の 宙返り飛行(){
digitalWrite(13,!digitalRead(13));//To Pulse LED, to show prgm is running
readTturePt1(tture[bWhichSensor]);//N.B.: Values passed 支援する in 全世界のs
延期する(1900);//This is "wait for 転換" (see webpage)
readTturePt2(tture[bWhichSensor]);//N.B.: Values passed 支援する in 全世界のs
延期する(50);
printTture();//N.B.: Takes values from 全世界のs.
Serial.print(" ");
if(bWhichSensor == 0){
Serial.print("\n");//Start new line
}
bWhichSensor++;
if(bWhichSensor == kTtureSensorMaxIndex+1){
bWhichSensor = 0;
}
/*"YOUR STUFF GOES HERE... if, for instance, you
making a 解雇する/砲火/射撃 alarm system, this is where you
put "if tture is too high, (犯罪の)一味 alarm bell".
-----------------------------
If you take steps to 確実にする that at least 1.9
seconds pass between the calls of...
readTturePt1
... and...
readTturePt2
... then, as long as you leave the pin associated
with the sensor alone, you can "do things"
during the time the system is waiting for the
転換 to 完全にする.
*/
}//end of 宙返り飛行()
/*Everything below here... just copy it into your program "as is".
That "should work". (There may, alaa, be a problem in readTturePt2.
See 公式文書,認めるs there.)
You are only likely to need to use readTture(pin) and printTture()
直接/まっすぐに. Others are subordinate to those.
These 決まりきった仕事s 接近 the に引き続いて 全世界の variables...
int TReading[], SignBit[], fTc_100[], Whole[], Fract[];
*/
無効の OneWireReset(int Pin) // reset. Should 改善する to 行為/法令/行動する as a presence pulse
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT); // bring low for 500 us
delayMicroseconds(500);
pinMode(Pin, INPUT);
delayMicroseconds(500);
}//end OneWireReset()
無効の OneWireOutByte(int Pin, byte d) // 生産(高) byte d (least sig bit first).
{
byte n;
for(n=8; n!=0; n--)
{
if ((d & 0x01) == 1) // 実験(する) least sig bit
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT);
delayMicroseconds(5);
pinMode(Pin, INPUT);
delayMicroseconds(60);
}
else
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT);
delayMicroseconds(60);
pinMode(Pin, INPUT);
}
d=d>>1; // now the next bit is in
// the least sig bit position.
}
}//end OneWireOutByte
byte OneWireInByte(int Pin) // read byte, least sig byte first
{
byte d, b;
d=0;/*This 批判的な line 追加するd 04 Oct 16
I hate to think how many derivatives of
this code 存在する どこかよそで on my web pages
which have NOT HAD this. You may "get away"
with not setting d to 無 here... but it
is A Very Bad Idea to 信用 to "hidden"
initializations!
The 事柄 was brought to my attention by
a 肉親,親類d reader who was THINKING OF YOU!!!
If YOU 位置/汚点/見つけ出す an error, please 令状 in, bring
it to my attention, to save the next person
grief.*/
for (bLoopCounter=0; bLoopCounter<8; bLoopCounter++)
{
digitalWrite(Pin, LOW);
pinMode(Pin, OUTPUT);
delayMicroseconds(5);
pinMode(Pin, INPUT);
delayMicroseconds(5);
b = digitalRead(Pin);
delayMicroseconds(50);
d = (d >> 1) | (b<<7); // 転換 d to 権利 and
//挿入する b in most sig bit position
}
return(d);
}//end OneWireInByte()
無効の readTturePt1(byte Pin){
/*This part starts the sensor doing a 転換,
i.e. taking a reading, and 蓄える/店ing result inside
itself.
This must be given time to 完全にする. The time necessary
is 影響する/感情d by how sensor is 力/強力にするd, and exact
sensor time. 1.8 seconds (yes, nearly 1/30th of a minute!)
should, off the 最高の,を越す of my 長,率いる, be enough, worst 事例/患者.
Other things can be happening while this is 存在
"given time"... just don't 乱す the 半導体素子.
Pass WHICH pin you want to read in "Pin"
Returns values in... (See 全世界の 宣言s)*/
OneWireReset(Pin);
OneWireOutByte(Pin, 0xcc);
OneWireOutByte(Pin, 0x44); // request 気温 転換,
// 持続する strong pullup while that is done.
}//end readTturePt1
無効の readTturePt2(byte Pin){
/*This part starts asks the sensor for the reading
it took "a moment ago", arising from the call
of readTturePt1
(This should have a "check that CheckSum isn't
報告(する)/憶測ing a problem" 追加するd to it... or else
a readTturePt3 should be 追加するd to do that.
Not "necessary", but A Very Good Idea!)
Pass the pin connected to the sensor you want
to read in "Pin"
Returns values in... (See 全世界の 宣言s)*/
int HighByte,LowByte;
OneWireReset(Pin);
OneWireOutByte(Pin, 0xcc);
OneWireOutByte(Pin, 0xbe);
LowByte = OneWireInByte(Pin);
HighByte = OneWireInByte(Pin);
//At this point, we SHOULD have the two bytes returned by the sensor 安全に
// 逮捕(する)d in LowByte and HighByte.
//Now we turn to 連合させるing them into a 気温 reading in
// more usual 部隊s.
//My work got 混乱させるd... does this return the tture in
// TReading in TENTHS of degree C or HUNDRETHS of degree C?
//The code 負かす/撃墜する to "end of 疑わしい section"... is やめる 嫌疑者,容疑者/疑う.
//Remember, if you have to work on it, that some DS18xx 半導体素子s encode
// the 気温s わずかに 異なって than others. Sigh.
//I'm not SURE which 半導体素子 this encoding is 権利 for...
//I think it is the DS18B20 (and others using the same
//data 判型.)
TReading[bWhichSensor] = (HighByte << 8) + LowByte;
SignBit[bWhichSensor] = TReading[bWhichSensor] & 0x8000; // 実験(する) most sig bit
if (SignBit[bWhichSensor]) // 消極的な
{
TReading[bWhichSensor] = (TReading[bWhichSensor] ^ 0xffff) + 1; // 2's comp
}
//At this point, we SHOULD have the two bytes returned by the sensor 安全に
fTc_100[bWhichSensor] = (6.0 * TReading[bWhichSensor]) + TReading[bWhichSensor] / 4.0;
//multiply by (100 * 0.0625) or 6.25
Whole[bWhichSensor] = fTc_100[bWhichSensor] / 100.0; // separate off the whole
//number and わずかの 部分s
//Now 除去する the 消極的な 調印する from 消極的な values in Whole...
if (Whole[bWhichSensor]<0) {Whole[bWhichSensor]= Whole[bWhichSensor]*-1;};
Fract[bWhichSensor] = round((fTc_100[bWhichSensor]-Whole[bWhichSensor])* 100);
}//end readTturePt2
void printTture(){//Uses values from global variables.
//See global declarations.
//N.B.: No new line inside printTture
//First, provide ID of sensor to output...
Serial.print("S");
Serial.print(bWhichSensor);
if (Whole[bWhichSensor] < 10)//To line up decimal points
//This assumes that no tture will be < -99.9 or > +99.0
//As these are in degrees C, that seems reasonable.
//And if a very high tture is measured, it will only
//slightly disturb the contents of the serial monitor.
{
Serial.print(" ");
}
if (SignBit[bWhichSensor]) // If it is negative
{
Serial.print("-");
}//no ; here
else
{
Serial.print("");
};//end of if... then... else...
Serial.print(Whole[bWhichSensor]);//Print the part of the reading
//which falls on the LEFT of the decimal point
Serial.print(".");
if (Fract[bWhichSensor] < 10)
{
Serial.print("0");
}
Serial.print(Fract[bWhichSensor]);//Print the part of the reading
//which falls on the RIGHT of the decimal point
}//end of printTture()
I hope the above Just 作品 for you. Do please 令状 and "complain", if not, as you may be saving the next person hassle you have had.
やめる a while ago (at 7/14), I 地位,任命するd a starting point, probably derived from デモs from Nuelectronics.
A 肉親,親類d reader sent in an 改善するd 見解/翻訳/版. Said 肉親,親類d reader is a 支持者 of the Australian charity Very Special Kids, if you want to show 評価 for the reader's 親切 to us all. (On its website, Very Special Kids says that its 使節団 is to support families of children with life-脅すing 条件s.)
The 肉親,親類d reader's 見解/翻訳/版 of the code, which went into what remains here, was for more 気温 sensors, and 改善するd the responsiveness of the program over my 初めの. (You now can 改訂する it to use few or many sensors.)
Subsequently, 2/19, another 肉親,親類d reader wrote, and brought その上の 問題/発行するs to my attention. Several hours later, the above was there for you. If YOU 位置/汚点/見つけ出す things, please 接触する me (詳細(に述べる)s below). Save the next person the questions that arose for you!
Each sensor will connect to a separate data line. The sensor will also have to connect to ground. If it 控訴s your circumstances, I would also eschew "parasitic 力/強力にするing"... but it should work, if you need it.
You will need to 供給(する) an 外部の pull-up resistor on the data line. Getting the 権利 value is a bit of a 黒人/ボイコット art... 協議する other pages for 詳細(に述べる)s. Some will tell you "the 権利 value", and if it 作品 for you, 広大な/多数の/重要な! But don't be surprised if you have to fiddle a bit to get good results. The good news: The 半導体素子s will tell you if a reading is "bad". (One of the 推論する/理由s a 数字表示式の sensor is so much better than something analog!)
That's pretty 井戸/弁護士席 it for "how to read one or more 気温 sensors with a microprocessor, e.g. Arduino".
支援する in the Bad Old Days when programming was Hard Work, I did やめる a lot with Dallas 1-Wire 半導体素子s. They have やめる fantastic 能力s, of which the above code doesn't avail itself at all. If you are 利益/興味d in learning more about 1-Wire 半導体素子 programming, in a 状況 probably more 関連した to 使用者s of "big" computers, I 申し込む/申し出 you my tutorials about programming for the Dallas 半導体 1-Wire (tm) 半導体素子s, as used on a MicroLan (tm). Those tutorials are written for Delphi (language) programmers, but they 含む/封じ込める much (警察などへの)密告,告訴(状) that would 適用する to other language 環境s. I also 持続する pages which introduce MicroLans and explain the 金物類/武器類.
If you have things that derive from earlier 見解/翻訳/版s: A few variables have been given better 指名するs. "Count" became bWhichSensor. X became bLoopCounter. Tc_100[] not only had an "f" pre-pended, but it also underwent a 批判的に necessary change of data type from "int" to "float".
I have written a 一連の essays which try to help you become a better Arduino programmer and engineer... but, for the best result, you will have to buckle 負かす/撃墜する and work your way through them in sequence. The collection of "How To's" this page comes from can be 接近d in whatever order you like.
Feel 解放する/自由な to use this (警察などへの)密告,告訴(状) in programming courses, etc, but a credit of the source would be 高く評価する/(相場などが)上がるd. If you 簡単に copy the pages to other web pages you will do your readers a disservice: Your copies won't stay 現在の. Far better to link to these pages, and then your readers see up-to-date 見解/翻訳/版s. For those who care- thank you- I have 地位,任命するd a page with more (警察などへの)密告,告訴(状) on what copyright 権利放棄s I 延長する, and suggestions for those who wish to put this 構成要素 on CDs, etc.
See the discussion 近づく the 底(に届く) of the "最高の,を越す level" page covering the 本体,大部分/ばら積みの of my Arduino 出資/貢献s. There is (警察などへの)密告,告訴(状) there, too, about things like "May I copy your 構成要素?", and the system of とじ込み/提出する 指名するs I am trying to work to.
If you visit 1&1's 場所/位置 from here, it helps me. They host my website, and I wouldn't put this link up for them if I wasn't happy with their service... although I was いっそう少なく than pleased the other day to have what I was doing interrupted by a telephone call from their sales team, trying to get me to 延長する my 関与. Sigh. Hardly a rare event, but I'd thought 1&1 were a bit classier that some of the people who have my telephone number.
Click here to visit editor's Sheepdog ソフトウェア (tm) freeware, shareware pages.
Click here to visit the homepage of my biggest 場所/位置.
Click here to visit the homepage of Sheepdogsoftware.co.uk. 陳謝s if the "?Frmar3ne1tt2" I 追加するd to that link 原因(となる)s your browser problems. Please let me know, if so?
Page has been 実験(する)d for 同意/服従 with INDUSTRY (not MS-only) 基準s, using the 解放する/自由な, 公然と accessible validator at validator.w3.org. Mostly passes.
....... P a g e . . . E n d s .....