program

Somebody could help me. I´m begining in write programm. I´m yet learning. This programm try to turn on light if the temperature get the set point. The problem is the yelow light remain on all the time. Here the error?

#include “DHT.h”

#define DHTPIN A0 // what pin we’re connected to
float h;
float t;
//int pinoRele = 8;
int pinLedVermelho = 5;
int pinLedBranco = 6;
int pinLedAmarelo = 7;
float temperatura;
float umidade;

// Uncomment whatever type you’re using!
#define DHTTYPE DHT11 // DHT 11
//#define DHTTYPE DHT22 // DHT 22 (AM2302)
//#define DHTTYPE DHT21 // DHT 21 (AM2301)
float setPoint = 27;
int valV = 0;
int valB = 0;
int valA = 0;

// Connect pin 1 (on the left) of the sensor to +5V
// Connect pin 2 of the sensor to whatever your DHTPIN is
// Connect pin 4 (on the right) of the sensor to GROUND
// Connect a 10K resistor from pin 2 (data) to pin 1 (power) of the sensor

DHT dht(DHTPIN, DHTTYPE);

//Declaração da Função Ler dados

float LerDados() {
// Reading temperature or humidity takes about 250 milliseconds!
// Sensor readings may also be up to 2 seconds ‘old’ (its a very slow sensor)
float h = dht.readHumidity();
umidade = h;
Serial.print("Humidity: “);
Serial.print(umidade);
float t = dht.readTemperature();
temperatura = t;
Serial.print(” %\ Temperatura ");
//Serial.print(“Temperature: “);
Serial.print(temperatura);
Serial.println(” *C”);
Serial.print(“Set Point “);
Serial.println(setPoint);
Serial.print(””);

Serial.print("Porta Vermelho = ");
Serial.println(valV);
Serial.print("Porta Branco = ");
Serial.println(valB);
Serial.print("Porta Amarelo = ");
Serial.println(valA);

delay(1500);

// check if returns are valid, if they are NaN (not a number) then something went wrong!
if (isnan(t) || isnan(h))
{
Serial.println(“Failed to read from DHT”);
}
}

void setup()
{
Serial.begin(9600);
pinMode(5,OUTPUT);
pinMode(6,OUTPUT);
pinMode(7,OUTPUT);
Serial.println(“DHTxx test!”);
dht.begin();
}

void loop()
{
LerDados();
if(temperatura < setPoint){
digitalWrite(5,HIGH);//Led vermelho menor que Set Point
digitalWrite(6,LOW);
digitalWrite(7,LOW);
valV = digitalRead(5);
}
// else if (temperatura == setPoint) {
// digitalWrite(5,LOW);
// digitalWrite(6,HIGH);
// digitalWrite(7,LOW);
// valB = digitalRead(6);
// }

else (temperatura > setPoint); {
digitalWrite(5,LOW);
digitalWrite(6,LOW);
digitalWrite(7,HIGH);
valA = digitalRead(7);
}
}

else (temperatura > setPoint); lose the expression and the semicolon.

Gain code tags.

To the compile, your ‘else’ looks like this:

  }
  else
    (temperatura > setPoint);


  {

What you wanted to say is:

  }
  else
  {

Becuse the compiler “sees” your program as looking like this:

void loop()
{
    LerDados();
    if(temperatura < setPoint){
        digitalWrite(5,HIGH);//Led vermelho menor que Set Point
        digitalWrite(6,LOW);
        digitalWrite(7,LOW);
        valV = digitalRead(5);
    }
    else 
        (temperatura > setPoint); 

    digitalWrite(5,LOW);
    digitalWrite(6,LOW);
    digitalWrite(7,HIGH);
    valA = digitalRead(7);
}