helo guys, ive done a code for a arduino to display the status of a water pump into a lcd, ive done it so that it reads if the motor is on or off, and display it into a lcd, the problem is that it always read as if the motor is on and it always displays de the message "bomba encendida" (it means pump on in spanish).
i havent done it on physical, just on proteus, what is wrong with the code? when i compile it it says its ok, no error messages
#include <LiquidCrystal.h>
LiquidCrystal lcd(7, 8, 9, 10, 11 , 12);
int bomba = 1;
int val = 0;
void setup() {
lcd.begin(16, 2);
lcd.setCursor(0, 0);
pinMode(bomba, INPUT);
}
void loop() {
val = digitalRead(bomba);
if(val = HIGH){
lcd.write("bomba1 encendida");
}
else{
lcd.write("bomba1 apagada");
}
}