Hello.
I am currently trying to make a fan that only spins if the temperature un the room is lower than the temperature set by the user. Currently, I have the following code :
#include <Adafruit_LiquidCrystal.h>
int tempRead = 0;
float tempVolt = 0;
float tempReal = 0;
Adafruit_LiquidCrystal lcd_1(0);
void setup()
{
pinMode(A0, INPUT);
pinMode(A1, INPUT);
pinMode(2, INPUT);
pinMode(4, INPUT);
lcd_1.begin(16, 2);
lcd_1.setBacklight(1);
lcd_1.print("Voulue :");
lcd_1.setCursor(0, 1);
lcd_1.print("Actuelle :");
}
void loop()
{
// Temp inputting stuff
lcd_1.setCursor(9, 0);
lcd_1.print(); // Print the wanted stuff
// Temp measuring stuff
int tempRead = analogRead(A1);
tempVolt = tempRead * 5.0;
tempVolt = tempVolt / 1024.0;
tempReal = (tempVolt - 0.5) * 100;
lcd_1.setCursor(11, 1);
lcd_1.print(tempReal);
}
Now, I need to set up two push buttons. One increases the wanted value by one (named userInput) and the other decreases it. But I really don't know how to do that. I've tested multiple things before, such as using
if (digitalRead(plusButtonPin == HIGH) )
{
userInput ++;
}
and
if (digitalRead(minusButtonPin == HIGH) )
{
userInput --;
}
but it doesn't work. Anyone got other ideas ?