Gast
#4961356
hallo.ich versuche es schon mehrere tage aber ohne erfolg stat analog
lm35 sensor digital ds18b20 sensor verwenden.
kann mir jemand bitte helfen bzw.Sketch-code schreiben,so das der CODE
mit ds 18b20 funktioniert.danke
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
#define sensorPin 0 // analog lm35 sensor
#define DELAY1 10
#define DELAY2 500
#define motorPin 9
#define threshold 25
#define hysterese 1
const int cycles = 20;
LiquidCrystal_I2C lcd(0X27,16,2)
void setup() {
pinMode(motorPin,OUTPUT);
lcd.init();
lcd.backlight();
}
void loop()
{
float resultTemp = 0.0;
for(int i = 0; i < cycles; i++){
int analogValue = analogRead(sensorPin);
float temperature = (5.0 * 100.0 * analogValue) / 1024;
resultTemp += temperature;
delay(DELAY1);
}
resultTemp /= cycles;
lcd.clear();
lcd.print("Temp:");
lcd.print(resultTemp);
#if ARDUINO < 100
lcd.print(0xD0 + 15, BYTE);
#else
lcd.write(0xD0 + 15);
#endif
lcd.print("C");
lcd.setCursor(0, 1);
lcd.print("MOTOR: ");
if(resultTemp > (threshold + hysterese))
digitalWrite(motorPin,HIGH);
if(resultTemp < (threshold + hysterese))
digitalWrite(motorPin,LOW);
lcd.print(digitalRead(motorPin) == HIGH?"an":"aus");
delay(DELAY2);
}