Hi ,
I have problem on programming LCD when the relay turns on or off the display doesn't show any thing but when i use display examples it works fine .
here is my sketch :
#include <LiquidCrystal.h>
LiquidCrystal lcd(12, 11, 5, 4, 3, 2);
int thisChar1 = 'LIGHT ON';
int thisChar2 = 'LIGHT OFF';
const int REL = 8;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(REL, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
digitalWrite(REL, HIGH);
delay(60000);
digitalWrite(REL, LOW);
delay(62000);
if (REL == HIGH)
{
lcd.print(thisChar1);
}
if (REL == LOW)
{
lcd.print(thisChar2);
}
}
i hope you can help me .
system
September 16, 2015, 7:39pm
2
if (REL == HIGH)
{
8 is not going to equal 1 any time soon.
if (REL == LOW)
Or zero, for that matter.
Please get used to using code tags when posting code.
sorry , but i am beginner in coding of arduino .
so what the code should be like when i want to display ON/OFF in this conditions.
system
September 17, 2015, 6:53am
4
You absolutely know when and what you wrote to the relay, so why are you testing anything?
What are you trying to do?
int thisChar1 = 'LIGHT ON';
That won't give you a compilation error, but it isn't remotely correct.
i am trying to make a 2 hour timer with 2 relay and LCD but i test on one now with this code :
#include <LiquidCrystal.h>
#define RELAY1 3
LiquidCrystal lcd(12, 11, 7, 6, 5, 4);
int runTimer = 1;
int runFor = 60;
int data = 0;
void setup() {
// put your setup code here, to run once:
lcd.begin(16, 2);
pinMode(RELAY1, OUTPUT);
}
void loop() {
// put your main code here, to run repeatedly:
if(runTimer == 1){
digitalWrite(RELAY1, HIGH);
lcd.setCursor(0,1);
lcd.print("LIGHT ON");
timer();
}
else {
digitalWrite(RELAY1, LOW);
lcd.setCursor(0,0);
lcd.print("LIHGHT OFF");
}
runTimer = 60;
}
void timer() {
for(int timer = runFor;timer > 0; --timer){
if(timer >= 10) {
lcd.setCursor(6,0);
} else {
lcd.setCursor(7,0);
lcd.print(" ");
lcd.setCursor(6,0);
}
lcd.print(timer);
lcd.setCursor(0,0);
lcd.print("Sec : ");
delay(1000);
}
lcd.clear();
}
but this count down for 60s and doesnt playpack again what i want to make is in the first 2 hour the first relay begin after the 2 hour gone the second relay start and the LCD display if the two relays are ON/OFF whic i plan to use it in a project .