#include //LCD Display LiquidCrystal lcd(7, 6, 5, 4, 3, 2); #define LM351 0 // LM35 auf Ausgang A0 (analog) setzen //int LM351 = A0; // output pin (PC0) of LM35 int vref = 2.601; //Atmega8-Ref.= 2.56V int fan1 = 10; // pin fan1 (PB2) B-->1k C-->Fan1(-) E-->(GND) (5-15V) int fan2 = 11; // pin fan2 (PB3) B-->1k C-->Fan2(-) E-->(GND) (5-15V) int ledLOW = 8; // led pin (PB0) (low) (green) when Fans are off (Status) int ledHIGH = 9; // led pin (PB1) (high) (red) when Fans are on int ledALERT = 12; // led pin (PB4) (ALERT)(Blue) when over MaxTemp int temp1Min = 30.00; // temperature when fan starts int temp1Max = 50.04; // maximum temperature fan reached 100% int fan1Speed; int fan2Speed; int fan1LCD; int fan2LCD; void setup() { pinMode(fan1, OUTPUT); pinMode(fan2, OUTPUT); pinMode(ledLOW, OUTPUT); //(green) for Fan off (Status) pinMode(ledHIGH, OUTPUT); //(red) for Fan starting (temp1Min Status) pinMode(ledALERT, OUTPUT); //(orange) when Overtemp (Status) pinMode(LM351, INPUT); // LM35 SensPin // pinMode(LM352, INPUT); analogReference(INTERNAL); // for ATMega8 2,56V internal Reference 2601; no Ref. 5000; lcd.begin(16, 2); } void loop(){ int temp1 = analogRead(LM351); byte measureCycles = 10; float millivolts = (temp1/1024.0) * 2585;//5000; Reference 2601;Ref. 2.56V Atmega8 (Ref.= 2.601V) "AKTUELL"(Ref.=2.585V) (Ref.= 2.740) float celsius = millivolts/10; if(celsius < temp1Min) { // if temp is lower than minimum temp fan1Speed = 0; // fan stop fan2Speed = 0; // fan stop digitalWrite(fan1, LOW); digitalWrite(fan2, LOW); } if((celsius >= temp1Min) && (celsius <= temp1Max)) { // if temperature is higher than minimum temp fan1Speed = map(celsius, temp1Min, temp1Max, 32, 255); // the actual speed of fan1 fan2Speed = map(celsius, temp1Min, temp1Max, 32, 255); // the actual speed of fan2 fan1LCD = map(celsius, temp1Min, temp1Max, 0, 100); // speed of fan to display on LCD fan2LCD = map(celsius, temp1Min, temp1Max, 0, 100); // speed of fan to display on LCD analogWrite(fan1, fan1Speed); // spin the fan1 at the fanSpeed analogWrite(fan2, fan2Speed); // spin the fan2 at the fanSpeed } // ledlow MD--------- if(celsius > temp1Min) { // if temp is lower than tempMin digitalWrite(ledLOW, HIGH); // turn on LED (green) if lower than tempMin } else { digitalWrite(ledLOW, LOW); // else turn of LED (green) if higher than tempMin } if(celsius >= temp1Min) { // if temp is higher or equal than tempMin digitalWrite(ledHIGH, LOW); // turn of LED (Orange) } else { digitalWrite(ledHIGH, HIGH); // turn on LED (Orange)from tempMin to tempMax } // ledALERT OverTEMP-------- if(celsius > temp1Max) { // if temp is higher than tempMax digitalWrite(ledALERT, LOW); // turn on LED (Red)when overTemp } else { digitalWrite(ledALERT, HIGH); // turn of LED (Red) } lcd.setCursor(0, 0); lcd.print("Temp:"); lcd.setCursor(6, 0); lcd.print(celsius); lcd.setCursor(12,0); // move cursor to first line(top position 9) lcd.print("C"); lcd.setCursor(0,1); // move cursor to next line (bottom left) lcd.print("F1:"); // Display Fan1 lcd.print(fan1LCD); // Display fanspeed lcd.setCursor(6,1); // move cursor to next line (bottom position 6) lcd.print("%"); // Display % lcd.setCursor(9,1); // move cursor to next line (bottom position 9) lcd.print("F2:"); // Display Fan2 lcd.print(fan2LCD); // display fanspeed lcd.setCursor(15,1); // move cursor to next line (bottom position 15) lcd.print("%"); delay(500); //delay(200); lcd.clear(); //Warte //delay(2000); //(2000) }