Показать сообщение отдельно
Старый 17.04.2016, 18:36   #262
Максимэ
Новый Пользователь
 
Регистрация: 15.09.2008
Возраст: 40
Город: на работе
Регион: 38
Машина: 99\MMC\Pajero IO
Сообщений: 25
Максимэ is on a distinguished road
По умолчанию

Как-то так!

Код:
#include <OneWire.h>
#include <DallasTemperature.h>
char incomingByte;
int analogInput = 0;
float vout = 0.0;
float vin = 0.0;
float R1 = 100000.0;
float R2 = 10000.0;
int value = 0;
OneWire OW_tempa(9);
OneWire OW_tempb(10);
OneWire OW_tempc(11);
DallasTemperature tempa(&OW_tempa);
DallasTemperature tempb(&OW_tempb);
DallasTemperature tempc(&OW_tempc);
DeviceAddress tempaAddress, tempbAddress, tempcAddress;
void setup(void){
Serial.begin(9600);
pinMode(analogInput,INPUT);
tempa.begin();
tempb.begin();
tempc.begin();
}
void loop(void){
  value = analogRead(analogInput);
  vout = (value*5.0)/1024.0;
  vin = vout/(R2/(R1+R2));
  if(vin<0.09){
    vin = 0.0;
  }
tempa.requestTemperatures();
delay(700);
Serial.print("<InDoor:");
if ( !tempa.getAddress(tempaAddress,0)){
Serial.print("0");
}else{
Serial.print(tempa.getTempCByIndex(0),1);
}
Serial.println(">");
tempb.requestTemperatures();
delay(700);
Serial.print("<OutDoor:");
if ( !tempb.getAddress(tempbAddress,0)){
Serial.print("0");
}else{
Serial.print(tempb.getTempCByIndex(0),1);
}
Serial.println(">");
tempc.requestTemperatures();
delay(700);
Serial.print("<Engine:");
if ( !tempc.getAddress(tempcAddress,0)){
Serial.print("0");
}else{
Serial.print(tempc.getTempCByIndex(0),1);
}
Serial.println(">");
delay(700);
Serial.print("<Voltage:");
Serial.print(vin,2);
Serial.println(">");
}
Максимэ вне форума   Ответить с цитированием