Advertisement
Guest User

Untitled

a guest
Mar 31st, 2016
100
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <OneWire.h>
  2. #include <DallasTemperature.h>
  3.  
  4. #define ONE_WIRE_BUS 2
  5. OneWire oneWire(ONE_WIRE_BUS);
  6. DallasTemperature sensors(&oneWire);
  7.  
  8. long lastReadingTime = 0;
  9.  float temp0 = sensors.getTempCByIndex(0);
  10.  float temp1 = sensors.getTempCByIndex(1);
  11.  
  12. void setup() {
  13.   // put your setup code here, to run once:
  14.   while(!Serial);
  15.   Serial.begin(9600);
  16.   sensors.begin();
  17.   sensors.setResolution(8);
  18.   sensors.requestTemperatures();
  19. }
  20.  
  21. void loop() {
  22.    if (millis() - lastReadingTime > 1000) {
  23.       sensors.requestTemperatures();
  24.      float temp0 = sensors.getTempCByIndex(0);
  25.      float temp1 = sensors.getTempCByIndex(1);
  26.     Serial.println(temp0);
  27.  
  28.       lastReadingTime = millis();
  29.     }
  30.  Serial.print("odczyt poza ifem ");
  31.  Serial.println(temp0);
  32.  
  33. }
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement