Help please!

Hi

I’m fairly new to arduino and I’m struggling with my sketch. I can’t seem to get it to work properly.

It seems like it’s something with the if’s. I can’t get the arguments to work. the lcd prints the prsV, no load, heating up and the temperature. When pressure is applied the temperature rises and the lcd prints no heat .

Please help me to see if i’ve gotten something wrong…

#include <Wire.h> 
#include <LiquidCrystal_I2C.h>
LiquidCrystal_I2C lcd(0x3F,16,2);  // set the LCD address to 0x3f for a 16 chars and 2 line display

const int temperaturePin1 = A1;    //temp sensor heater
const int temperaturePin2 = A2;    // temp sensor animal 
const int prs_Pin = A0;           // pressure sensor

const float VCC = 4.65; // Measured voltage of Ardunio 5V line
const float R_DIV = 4700; // Measured resistance of 4,7k resistor

int relayPin1 = 8;  // Pin of Relay Module start heater
int relayPin2 = 7;  // Pin of Relay Module  coling fan
int relayPin3 = 6;  // Pin of Relay Module sensor heater
int relayPin4 = 5;  // Pin of Relay Module circulation


void setup()
{
 pinMode(relayPin1, OUTPUT);
 pinMode(relayPin2, OUTPUT);
 pinMode(relayPin3, OUTPUT);
 pinMode(relayPin4, OUTPUT);  // Set Pin connected to Relays as an OUTPUT
 pinMode(prs_Pin, INPUT);     //  Set Pin connected to relays as an input
 
 digitalWrite(relayPin1,0);
 digitalWrite(relayPin2,0);
 digitalWrite(relayPin3,0); 
 digitalWrite(relayPin4,0);   // Set Pin to 0 to turn Relays OFF

lcd.init();                      // initialize the lcd 

lcd.backlight();


}


void loop()
{
 
 
 int prsADC = analogRead(prs_Pin); // If the prs has no pressure, the resistance will be near infinite. So the voltage should be near 0.
 float prsV = prsADC * VCC / 1023.0;   //stämmer
 
 float voltage, degreesC1, voltage2, degreesC2;

voltage = getVoltage(temperaturePin1);
degreesC1 = ( (voltage * 100)-4 );
 voltage2 = getVoltage(temperaturePin2);
degreesC2 = ((voltage2 * 100));

if (prsV < 0,03){      // If the analog reading is near zero
   lcd.setCursor (5,0);
   //lcd.print(prsV);
   lcd.print("no load");
   
 if (degreesC1 < 30){
 digitalWrite(relayPin1, 1);
 lcd.setCursor (0,1);
 lcd.print("heating up ");
 lcd.print(degreesC1);
 lcd.setCursor (0,0);
 lcd.print(prsV);
 }
 else 
 {  
 digitalWrite(relayPin1, 0);
   lcd.clear();
   lcd.setCursor (0,1);
 lcd.print("no heat");
   lcd.setCursor (11,1);
   lcd.print(degreesC1);
   lcd.print(prsV);
 }
}  

  
  
else
{
 lcd.clear();
 lcd.setCursor (5,0);
 lcd.print("load on");
 //delay(1000);
    
    if(degreesC2 < 38){
        digitalWrite(relayPin1, 1);
        lcd.setCursor (0,0);
        lcd.print("heating ");
        lcd.print(degreesC2);
     }
     else if(degreesC2 < 40){
       //digitalWrite(relayPin1, 0);
      // digitalWrite(relayPin2,1);
       lcd.setCursor (1,0);
       lcd.print("circulation");
     }
     else 
     {
       digitalWrite(relayPin1, 0);
       digitalWrite(relayPin2, 0);
       digitalWrite(relayPin3, 1);
       lcd.setCursor (1,1);
       lcd.print("cooling");
      }
}

  
 

 
delay (1000);
}


float getVoltage(int pin)
{
return (analogRead(pin) * 0.004882814);
}

Thanks!

Please modify your post and use the code button </> so your code looks like this and is easy to copy to a text editor. See How to use the Forum Your code is too long for me to study quickly without copying to a text editor.

…R

  if (prsV < 0, 03)      // If the analog reading is near zero

Not how you test if a value is in a range

 if (prsV >= 0 && psrV <= 3) //if the reading is between 0 and 3

One thing that caught my eye

if (prsV < 0,03)

Change the comma to a dot.

  pinMode(prs_Pin, INPUT);     //  Set Pin connected to relays as an input

prs_Pin has a relay attached?

const int prs_Pin = A0;           // pressure sensor

That makes that comment look pretty stupid, then.

Since you are using prs_Pin as an analog pin, you almost certainly do not want to be diddling with the digital nature of that pin, which is what pinMode() does.

Thanks you all, Its now working!!!!

Most of the topics on this forum are requests for help, so a subject of "Help please!" is not useful. Polite, perhaps, but not useful.