HELP :)

basically i have to make a greenhouse temperature sensor. i have a min temp value that if reached an led(representing a vent) goes on when a pushbutton is pressed. then goes off when i push button again when vent open. theres a second threshold temp that if reached another led turns on(representing a fan) when pushbutton and stays on untill pushbutton pressed again and then the whole thing in reverse. an lcd screen is attached showing the change in temperature… any help would be greatly appreciated thanks :smiley: :grin:

LiquidCrystal lcd(12,11,5,4,3,2);
int sensor =A1;
int button =7;
int ledVent =8;
int ledFan =9;
const float baslineTemp =20.0;
const float upperLine =25.0;
int fanSpeed;
int fanLCD;
float readTemp(void);
float readTemp;

void setup() {
serial.begin(9600);
pinMode(ledVent, OUTPUT);
pinMode(ledFan, OUTPUT);
pinMode(button, INPUT);
pinMode(sensor, INPUT);
lcd.begin(16,2);
}

void loop() {
int sensorVal = analogRead(sensor);
temp = readTemp(); // get the temp
if(temp < tempMin) { //if lower than min temp
fanSpeed =0; //fan not spinning
digitalWrite(ledVent, LOW)
digitalWrite(ledFan, LOW)
}
if((temp >= tempMin) && (temp <= tempMax)) // if higher than min and below max
val = digitalRead(button); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledVent, LOW); // turn LED OFF
} else {
digitalWrite(ledVent, HIGH); // turn LED ON
}
if(temp > tempMax) {
val = digitalRead(button); // read input value
if (val == HIGH) { // check if the input is HIGH (button released)
digitalWrite(ledFan, LOW); // turn LED OFF
} else {
digitalWrite(ledFan, HIGH); // turn LED ON
}

{
int sensorVal = analogRead(sensor);
lcd.print(“sensor Value:”);
lcd.print(sensorVal);
float voltage = (sensorVal/1024.0) * 5.0; // converting adc to voltage
lcd.print(",Volts: “):
lcd.print(voltage);
lcd.print(”,degress C: "); // converting volts to temp
float temperature = (voltage - .5) * 100;
lcd.print(temperature);
}

Looks like you need a { after this line

if((temp >= tempMin) && (temp <= tempMax)) // if higher than min and below max

and delete the { before this line

int sensorVal = analogRead(sensor);

thanks :smiley:

im getting these errors would ??

Arduino: 1.6.0 (Windows 8), Board: “Arduino Uno”

sketch_apr30a.ino:1:1: error: ‘LiquidCrystal’ does not name a type
sketch_apr30a.ino:11:7: error: ‘float readTemp’ redeclared as different kind of symbol
sketch_apr30a.ino:10:7: error: previous declaration of ‘float readTemp()’
sketch_apr30a.ino: In function ‘void setup()’:
sketch_apr30a.ino:15:1: error: ‘serial’ was not declared in this scope
sketch_apr30a.ino:20:1: error: ‘lcd’ was not declared in this scope
sketch_apr30a.ino: At global scope:
sketch_apr30a.ino:24:1: error: expected initializer before ‘int’
sketch_apr30a.ino:25:1: error: ‘temp’ does not name a type
sketch_apr30a.ino:26:1: error: expected unqualified-id before ‘if’
sketch_apr30a.ino:31:1: error: expected unqualified-id before ‘if’
Error compiling.

This report would have more information with
“Show verbose output during compilation”
enabled in File > Preferences.

#include <LiquidCrystal.h>
LiquidCrystal lcd(2, 3, 4, 5, 11, 12);

just edit it like that :wink:
<LiquidCrystal.h> this is a library arduino use it to understand how that LCD work
and don’t forget use a resistor with your button

perfect thanks for the help :smiley:

:wink: you are welcome
anyway, if you have future errors, try to separate the code, make your LCD work first, then add temperature, then more options...
it's more helpful for you, to know what are you doing, & to learn each code line for what