Alarms.ino 608 B

1234567891011121314151617181920212223242526272829303132
  1. #include <DS18B20.h>
  2. #define LOW_ALARM 20
  3. #define HIGH_ALARM 25
  4. DS18B20 ds(2);
  5. void setup() {
  6. Serial.begin(9600);
  7. while (ds.selectNext()) {
  8. ds.setAlarms(LOW_ALARM, HIGH_ALARM);
  9. }
  10. }
  11. void loop() {
  12. ds.doConversion();
  13. while (ds.selectNextAlarm()) {
  14. Serial.print("Alarm Low: ");
  15. Serial.print(ds.getAlarmLow());
  16. Serial.println(" C");
  17. Serial.print("Alarm High: ");
  18. Serial.print(ds.getAlarmHigh());
  19. Serial.println(" C");
  20. Serial.print("Temperature: ");
  21. Serial.print(ds.getTempC());
  22. Serial.println(" C\n");
  23. }
  24. delay(10000);
  25. }