problem program

hi everyone,
my name is Simon and i have a project for school. I need to make a heated water container for my chicken so the water didn’t freeze i the winter.

So, i have to relais and al led.

  • If the temperature sensor goes below 5°C, relais 1 goes on. (pomp starts comping the water so it circulates).
  • If the temperature sensor goes below 3°C, relais 2 and the led are going on. (heating element starts heating and the red led goes on(.
    -if the temperature sensor goes back above 6°C, relais 2 and the led shuts down.

i made a program for it but it’s not working. What do i do wrong?

Setup: potentiometer, 2x relais, led

Code:

const int sensor = A0;
const int pomp = 2;
int heat = 3;
const int led = 4;

void setup() {

pinMode(pomp, OUTPUT);
pinMode(heat, OUTPUT);
pinMode(led, OUTPUT);

Serial.begin(9600); // de analoge waarde gaat tot 9600
}

void loop() {
int analogValue = analogRead(sensor); // de waarde van de temparatuur sensor word gelezen

if(analogValue < 500); // als de temparatuur kleiner is dan 5°C
{
digitalWrite(pomp, HIGH); // de pomp gaat aan
}

if(analogValue < 300); // als de temparatuur kleiner is dan 3°C
{
digitalWrite(heat, HIGH); // het warmte element gaat aan
digitalWrite(led, HIGH); // de rode led gaat aan
}

if((analogValue < 600); // als de temparatuur kleiner is dan 6°C EN het warmteelement is aan
{
digitalWrite(heat, LOW); // het warmte element gaat uit
digitalWrite(led, LOW); // de rode led gaat uit
}

Serial.println(sensor); // print de informatie van de sensor op je ‘serial monitor window’
delay(2); // pauze van 2 milliseconden

}

Thanks for helping me.

DrinkbakCode2.0.ino (1.32 KB)

First, please use code tags to post your code.

Second, all of your if statements have a semi-colon at their end - remove them.

Third, in this example (with code tags):

if((analogValue < 600);

That less than, should be greater than.

Finally, it seems odd that your temperature sensor provides voltage corresponding to temperature in that fashion - does it really?

if((analogValue < 600);

lose the semicolon

I did send you a personal message (in Dutch) about your problem(s)

DrinkbakCode3.0.ino (2.88 KB)