Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Arduino IDE demo source code for KC868-A16]--#05-DS18B20
#1
Rainbow 
Code4: //The demo code is DS18B20    You can copy the code to your Arduino IDE

Code:
#include <DS18B20.h>

#define LOW_ALARM 10
#define HIGH_ALARM 15

DS18B20 ds(33);   //PIN #33
uint8_t address[] = {40, 168, 111, 11, 44, 32, 1, 185};
uint8_t selected;

void setup() {
  Serial.begin(9600);
  selected = ds.select(address);

  if (selected) {
    ds.setAlarms(LOW_ALARM, HIGH_ALARM);
  } else {
    Serial.println("Device not found!");
  }
}

void loop() {
  if (selected) {
    if (ds.hasAlarm()) {
      Serial.print("Warning! Temperature is ");
      Serial.print(ds.getTempC());
      Serial.println(" C");
    }
  } else {
    Serial.println("Device not found!");
  }

  //delay(10000);
}
       
Reply


Forum Jump:


Users browsing this thread:
1 Guest(s)