I am currently working on a bigger project and right now i am having a issue with finding out how to use + - to increment or decrement the chosen values.
Right now i have them set only on temperature but i would like to change this so i can choose the variable i want to set before increasing or decreasing the value.
i also want to be able to set some clock values for a timer. turning on and off lights at the set hour and minute.
so what i want to do is: (and need help with)
Hit IR Button
- temperature setting (+ - to increment/decrement by 0.5C)
- evening time light turn off (+ - to increment/decrement hours and minutes)
- morning time light turn on (+ - to increment/decrement hours and minutes)
i also want to be able to override the lights with a buttonpush at any other time but i dont think that should be a problem .
the relevant code i have this faar on this problem is:
for the ir Control
void irsignal()
{
if (irrecv.decode(&results)) //Result from remote and store in IRecieved
{
IReceived = results.value;
//Serial.println(results.value);
update = 0;
switch (IReceived)
{
case playpause:
update = 7;
lcdDimLights(1);
break;
case button1:
openCloseDoor();
lcdDimLights(0);
break;
case button2:
lcdDimLights(0);
break;
case button3:
lcdDimLights(0);
break;
case button4:
update = 1;
lcdDimLights(0);
break;
case button5:
update = 2;
lcdDimLights(0);
break;
case button6:
update = 3;
lcdDimLights(0);
break;
case button7:
update = 4;
lcdDimLights(0);
break;
case button8:
update = 5;
lcdDimLights(0);
break;
case button9:
update = 6;
lcdDimLights(0);
break;
case buttonminus:
update = 8;
decreaseTemperature();
lcdDimLights(0);
break;
case buttonplus:
update = 8;
increaseTemperature();
lcdDimLights(0);
break;
case EQ:
update = 7;
lcdDimLights(0);
lcd.setCursor ( 0, 1 );
lcd.print("Smart SeedHouse ");
break;
}
irrecv.resume();
}
}
for the Lights
int eveningHour;
int eveningMinute;
int morningHour;
int morningMinute;
void timerLight()
{
if (hour() == eveningHour && minute() == eveningMinute)
{
digitalWrite(whiteLights, HIGH);
digitalWrite(plantLights, HIGH);
}
else if (hour() == morningHour && minute() == morningMinute)
{
digitalWrite(whiteLights, LOW);
digitalWrite(plantLights, LOW);
}
}
for the temperature
float temperatureNow = 0;
float setTemperature = 25; // legge til ir setting av temp...
void increaseTemperature()
{
if (setTemperature >= 35) // This is the max limit temperature for the SeedHouse
{ // we therefore keep this lot empty as we dont want to increase temp any more
}
else if (setTemperature < 35)
{
setTemperature = setTemperature + 0.5;
}
}
void decreaseTemperature()
{
if (setTemperature > 20) // This is the minimum limit temperature for the SeedHouse
{
setTemperature = setTemperature - 0.5;
}
else if (setTemperature <= 20) // We dont want to decrease temperature more than this
{
}
}
and the void loop
void loop()
{
sensors.requestTemperatures();
// Update for getting live numbers on lcd screen.
if (update == 1)
{
topSensor();
}
else if (update == 2)
{
bottomSensor();
}
else if (update == 3)
{
temperatureProbe1();
}
else if (update == 4)
{
temperatureProbe2();
}
else if (update == 5)
{
temperatureProbe3();
}
else if (update == 6)
{
temperatureProbe4();
}
else if (update == 7)
{
actualTemperature();
}
else if (update == 8)
{
setTemperatureShow();
}
else if (update == 9)
{
setTemperatureShow();
}
if (timer > 50) // Time between DHT22 sensorReads
{
sensorRead();
timer = 0;
}
timer++;
timerLight();
heaterCell();
fanControl();
earthMoisture();
irsignal();
digitalClockDisplay();
lcdDimTimer();
}
Clock im using
void printDigits(int digits)
{
lcd.print(':');
if(digits < 10)
lcd.print('0');
lcd.print(digits);
}
void digitalClockDisplay(void)
{
lcd.home ();
lcd.print(day());
lcd.print('.');
lcd.print(month());
lcd.print('.');
lcd.print(year());
lcd.print(' ');
lcd.print(hour());
printDigits(minute());
printDigits(second());
}