SHARE
TWEET

Untitled

a guest Oct 22nd, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // Program odczytuje temperaturę z czujnika
  2.  
  3. #include <OneWire.h>
  4. #include <DS18B20.h>
  5.  
  6. // Numer pinu do którego podłaczasz czujnik
  7. #define ONEWIRE_PIN 2
  8.  
  9. // Adres czujnika
  10. byte address[8] = {0x28, 0xFF, 0xB9, 0xB3, 0xA1, 0x17, 0x5, 0xD};
  11.  
  12. OneWire onewire(ONEWIRE_PIN);
  13. DS18B20 sensors(&onewire);
  14.  
  15. void setup() {
  16.   while(!Serial);
  17.   Serial.begin(9600);
  18.  
  19.   sensors.begin();
  20.   sensors.request(address);
  21.  
  22. }
  23.  
  24.   int ile = 0;
  25.   float tablica[18];
  26.  
  27. void loop() {
  28.   while (ile < 18)
  29.   {
  30.     if (sensors.available())
  31.     {
  32.       float temperature = sensors.readTemperature(address);
  33.       Serial.print(ile);
  34. //      Serial.print(temperature);
  35. //      Serial.println(F(" 'C"));
  36.       tablica[ile]= temperature;
  37.       sensors.request(address);
  38.       ile ++;
  39.     }
  40.   }
  41.   if (ile == 18)
  42.   {
  43.     float minimum, maksimum;
  44.     float suma = 0;
  45.     minimum = tablica[0];
  46.     maksimum = tablica[0];
  47.     for (int i=0; i<18; i++)
  48.     {
  49.       suma += tablica[i];
  50.       if (tablica[i] < minimum) minimum = tablica[i];
  51.       if (tablica[i] > maksimum) maksimum = tablica[i];
  52.     //  Serial.print(i);
  53.     //Serial.print(tablica[i]);
  54.     //Serial.println(F(" 'C"));  
  55.     }
  56.     suma -= minimum;
  57.     suma -= maksimum;
  58.     suma /= 16;
  59.     Serial.println(F("suma: "));
  60.     Serial.println(suma);
  61.     Serial.println(F(" 'C"));
  62.     ile=0;
  63.   }
  64.  
  65.   // tu umieść resztę twojego programu
  66.   // Będzie działał bez blokowania
  67. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top