Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <DallasTemperature.h>//dołączenie bibliotek do obsługi czujnika temperatury
- #include <OneWire.h>
- OneWire oneWire(A5);//zdefiniowanie pinu dla czujnika DS18B20
- DallasTemperature sensors(&oneWire);//zadeklarowanie nowego obiektu sensors, komunikującego się z Arduino przezOneWire
- void setup() {
- Serial.begin(9600);//uruchamianie komunikacji przez UART
- sensors.begin();//Inicjalizacja czujników
- }
- void loop() {
- sensors.requestTemperatures();//Pobranie temperatury czujnika
- Serial.print("Pierwszy: ");
- Serial.print(sensors.getTempCByIndex(0));//Wyświetlenie temperatury w stopniach Celsjusza z czujnika 0
- Serial.print("\tDrugi: ");
- Serial.println(sensors.getTempCByIndex(1));//Wyświetlenie temperatury w stopniach Celsjusza z czujnika 1
- delay(500);
- }
Add Comment
Please, Sign In to add comment