Hello, I want to combine two different codes one for the "Push Button Switch" and one for the "LCD display".
What I want to do is when I press on the switch it will show on the LCD "On" and when I depress it it will show "Off"
below is the code I use in my switch, help me on this please , thank you!!!
const int buttonPin = 2;
const int ledPin = 13;
int buttonState = 0;
void setup() {
pinMode(ledPin, OUTPUT);
pinMode(buttonPin, INPUT);
}
void loop() {
buttonState = digitalRead(buttonPin);
if (buttonState == HIGH) {
digitalWrite(ledPin, HIGH);
} else {
digitalWrite(ledPin, LOW);
}
}
We need to know which exact LCD that you have. Have you connected the display? Have you tried any of the LCD library examples?
How is the switch wired?
What is the question? What does the sketch do for the moment?
system
4
bendave71:
when I press on the switch it will show on the LCD "On" and when I depress it it will show "Off"
Just checking that when you say "depress" you mean "release"?
"Depress" as a verb actually means the same as press, not "un-press":
push or pull (something) down into a lower position.
"depress the lever"
Is this a school project for your degree?