In general, a pin is either an input or an output. So you either read it or you write it. You however read a pin and next write that same pin.
So you need to declare two other pins for the outputs. For now we assume that you will control using relays.
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// input and output pins
const int humiditySensor = A0;
const int temperatureFan = A1;
const int relayHumidifier = 12;
const int relayHeater = 11;
// humidity and temperature
int sensorValue1;
int sensorValue2;
Note the use of the const keyword; the compiler will warn you if you try to assign a value to them by accident.
Although sensorValue1 and sensorValue2 are acceptable names, why don't you give them a name that really reflects what is stored in them? So the above could change to
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
// input and output pins
const int humiditySensor = A0;
const int temperatureFan = A1;
const int relayHumidifier = 12;
const int relayHeater = 11;
// humidity and temperature
int humidity;
int temperature;
The result of an analogRead() is always a positive number from 0 to 1023. So your 'intended' test will always be true (and the test that you implemented will also always be true because himiditySensor equals A0 which is the value 14).
Let's assume that a humidity value of 512 equals 50% and you want to switch the humidifier on when the humidity drops below 50%.
void loop()
{
// read humidity
humidity = analogRead(humiditySensor);
// if less than 50%
if (humidity < 512)
{
// humidifier on
digitalWrite(relayHumidifier, HIGH);
}
else
{
// humidifier off
digitalWrite(relayHumidifier, LOW);
}
// rest of code
...
...
}
This leaves us with the setup() function.
void setup()
{
// output pins
pinMode(relayHumidifier, OUTPUT);
pinMode(relayTemperature, OUTPUT);
// input pins
// analog pins don't require specific setup.
}
terminator15:
The humidity will be controlled by a usb bottle humidifier
Please explain what an usb bottle humidifier is. The word 'usb' in there worries me a bit.