Good day
My project is a complete temperature monitor using %x LM35 sensors and displaying the info on 16x2 lcd.
My goal is to make the LEDs blink non stop when my temp has reached max settings.
My code:
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int CPUPin = 0; // CPU temp pin
int GPUPin = 1; // GPU temp pin
int MBDPin = 2; // Motherbourd temp pin
int HDD1Pin = 3; // Harddrive 1 temp pin
int HDD2Pin = 4; // Harddrive 2 temp pin
int CPULED = 6; // CPULED pin
int GPULED = 7; // GPULED pin
int MBDLED = 8; // Motherboard LED pin
int HDD1LED = 9 // Harddrive 1 LED pin
int HDD2LED = 10; // Harddrive 2 LED pin
int hotCPU = 60; // CPU max temp
int hotGPU = 85; // GPU max temp
int hotMBD = 40; // Motherboard max temp
int hotHDD1 = 35; // Harddrive 1 max temp
int hotHDD2 = 35; // Harddrive 2 max temp
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(CPULED, OUTPUT);
pinMode(GPULED, OUTPUT);
pinMode(MBDLED, OUTPUT);
pinMode(HDD1LED, OUTPUT);
pinMode(HDD2LED, OUTPUT);
}
void loop() {
{{{{
// put your main code here, to run repeatedly:
int value = analogRead(CPUPin);
lcd.setCursor(0, 1);
float milivolts = (value / 1024.0) * 5000;
float celsius = milivolts / 10;
lcd.clear();
lcd.print(" C P U:");
lcd.setCursor(3, 1);
lcd.print( celsius);
lcd.print(" \337C");
lcd.setCursor(0, 1);
if (celsius > hotCPU)
digitalWrite(CPULED, HIGH);
else digitalWrite(CPULED, LOW);
delay(1000);
}
{
lcd.clear();
int value = analogRead(GPUPin);
float milivolts = (value / 1024.0) * 5000;
float celsius = milivolts / 10;
lcd.setCursor(0, 1);
lcd.clear();
lcd.print(" GRAPHICS CARD:");
lcd.setCursor(3, 1);
lcd.print( celsius);
lcd.print(" \337C");
lcd.setCursor(0, 1);
if (celsius > hotGPU)
digitalWrite(GPULED, HIGH);
else digitalWrite(GPULED, LOW);
delay(1000);
}
{
lcd.clear();
int value = analogRead(MBDPin);
float milivolts = (value / 1024.0) * 5000;
float celsius = milivolts / 10;
lcd.setCursor(0, 1);
lcd.clear();
lcd.print(" MOTHERBOARD:");
lcd.setCursor(3, 1);
lcd.print( celsius);
lcd.print(" \337C");
lcd.setCursor(0, 1);
if (celsius > hotMBD)
digitalWrite(MBDLED, HIGH);
else digitalWrite(MBDLED, LOW);
delay(1000);
}
{
lcd.clear();
int value = analogRead(HDD1Pin);
float milivolts = (value / 1024.0) * 5000;
float celsius = milivolts / 10;
lcd.setCursor(0, 1);
lcd.clear();
lcd.print("500GB HARDDRIVE:");
lcd.setCursor(3, 1);
lcd.print( celsius);
lcd.print(" \337C");
lcd.setCursor(0, 1);
if (celsius > hotHDD1)
digitalWrite(HDD1LED, HIGH);
else digitalWrite(HDD1LED, LOW);
delay(1000);
}
{
lcd.clear();
int value = analogRead(HDD2Pin);
float milivolts = (value / 1024.0) * 5000;
float celsius = milivolts / 10;
lcd.setCursor(0, 1);
lcd.clear();
lcd.print(" 2TB HARDDRIVE:");
lcd.setCursor(3, 1);
lcd.print( celsius);
lcd.print(" \337C");
lcd.setCursor(0, 1);
if (celsius > hotHDD2)
digitalWrite(HDD2LED, HIGH);
else digitalWrite(HDD2LED, LOW);
delay(1000);
}
}
}
}
}