/
nicodim4
/
Arduino-Temperature-Control-Library
Обзор
Документация
Войти
/
nicodim4
/
Arduino-Temperature-Control-Library
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
examples/SetUserData/SetUserData.ino
47 строк
1 KB
Karl G
Normalize line endings and fix inconsistencies in whitespace
02 янв 2021, 04:41
02 янв 2021, 04:41
f3eb5d0
Код
Авторство
О чём код?
// // This sketch does not use the ALARM registers and uses those 2 bytes as a counter // these 2 bytes can be used for other purposes as well e.g. last temperature or // a specific ID. // #include <OneWire.h> #include <DallasTemperature.h> // Data wire is plugged into port 2 on the Arduino #define ONE_WIRE_BUS 2 // Setup a oneWire instance to communicate with any OneWire devices (not just Maxim/Dallas temperature ICs) OneWire oneWire(ONE_WIRE_BUS); // Pass our oneWire reference to Dallas Temperature. DallasTemperature sensors(&oneWire); int count = 0; void setup(void) { // start serial port Serial.begin(9600); Serial.println("Dallas Temperature IC Control Library Demo"); // Start up the library sensors.begin(); } void loop(void) { // call sensors.requestTemperatures() to issue a global temperature // request to all devices on the bus Serial.print("Requesting temperatures..."); sensors.requestTemperatures(); // Send the command to get temperatures Serial.println("DONE"); Serial.print("Temperature for the device 1 (index 0) is: "); Serial.println(sensors.getTempCByIndex(0)); count++; sensors.setUserDataByIndex(0, count); int x = sensors.getUserDataByIndex(0); Serial.println(count); }