Hi
I have the code below it works fine but i would like the pwm to be at 255 until the temperature gets to
55 c
and then run the code i have if temperature is greater than 55
this part of my code i can't get to work but it does compile
if (temp <=0)
{
analogWrite(hho, val /255);
lcd.print(hhoLCD);
}
else if (temp >= 55)
thanks in advance
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <max6675.h>
#define csTC1 10
LiquidCrystal_I2C lcd(0x27, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE);
int thermoDO = 8; //so
int thermoCS = 9; //cs
int thermoCLK = 10; //ss
MAX6675 thermocouple(thermoCLK, thermoCS, thermoDO);
int vccPin = 3;
int gndPin = 2;
int tempPin = A1; // the output pin of LM35
int hho = 11; // the pin where fan is
int temp;
int tempMin = 0; // the temperature to start the fan
int tempMax = 73; // the maximum temperature when fan is at 100%
int hhoSpeed;
int hhoLCD;
float vout = 0.0;
float vin = 0.0;
float R1 = 30000.0; // resistance of R1 (100K)
float R2 = 7500.0; // resistance of R2 (10K)
int value = 0;
int mVperAmp = 66; // use 100 for 20A Module and 66 for 30A Module
int RawValue = 0;
int ACSoffset = 2500;
double Voltage = 0;
int val = 0;
double Amps = 0;
const int analogIn = A0;
uint8_t degree[8] = {140, 146, 146, 140, 128, 128, 128, 128};
void setup() {
Serial.begin(9600);
pinMode(vccPin, OUTPUT); digitalWrite(vccPin, HIGH);
pinMode(gndPin, OUTPUT); digitalWrite(gndPin, LOW);
pinMode(hho, OUTPUT);
pinMode(tempPin, INPUT);
lcd.begin(20, 4);
lcd.createChar(0, degree);
}
void loop() {
(Voltage, 2);
temp = readTemp();
if (temp <=0)
{
analogWrite(hho, val /255);
lcd.print(hhoLCD);
}
else if (temp >= 65)
hhoSpeed = map(temp, tempMax, tempMin, 0, 255); // the actual speed of fan
hhoLCD = map(temp, tempMax, tempMin, 0, 100); // speed of fan to display on LCD
analogWrite(hho, hhoSpeed); // spin the fan at the fanSpeed speed
{
}
if ((temp <= tempMaxb) && (temp >= tempMinb)) { // if temperature is higher than minimum temp
hhoSpeed = map(temp, tempMaxb, tempMinb, 0, 255); // the actual speed of fan
hhoLCD = map(temp, tempMaxb, tempMinb, 0, 100); // speed of fan to display on LCD
analogWrite(hho, hhoSpeed); // spin the fan at the fanSpeed speed
}
(Voltage, 2); // the '3' after voltage allows you to display 3 digits after decimal point
lcd.print("Temp ");
lcd.print(temp); // display the temperature
lcd.print((char)223);
lcd.setCursor(10, 0); // move cursor to next line
lcd.print("Cell ");
lcd.print(hhoLCD); // display the fan speed
lcd.print("%");
lcd.setCursor(0, 1);
lcd.print("Amps "); // shows the voltage measured
lcd.print(Amps, 1);
lcd.setCursor(10, 1);
lcd.print("Volts ");
lcd.print(vin, 2);
lcd.setCursor(0, 2);
lcd.print("Oil ");
lcd.print(thermocouple.readCelsius());
#if ARDUINO >= 100
lcd.print((char)223);
#else
lcd.print(0, BYTE);
#endif
delay(1000);
delay(200);
lcd.clear();
}
int readTemp() { // get the temperature and convert it to celsius
temp = analogRead(tempPin);
return temp * 0.073328125;
}