So, I have made a simple circuit using an LCD and a button, so that when I press the button, the LCD should show "don't touch me!", which it does. And when I am not pressing the button, the LCD doesn't show anything, which is what I want. My problem is that when I press the button to show "don't touch me!", it shows that but the text is flickering. I am a beginner to this, only been on a few days. here is the code:
The circuit:
* LCD RS pin to digital pin 12
* LCD Enable pin to digital pin 11
* LCD D4 pin to digital pin 5
* LCD D5 pin to digital pin 4
* LCD D6 pin to digital pin 3
* LCD D7 pin to digital pin 2
* LCD R/W pin to ground
* LCD VSS pin to ground
* LCD VCC pin to 5V
* 10K resistor:
* ends to +5V and ground
* wiper to LCD VO pin (pin 3)
Library originally added 18 Apr 2008
by David A. Mellis
library modified 5 Jul 2009
by Limor Fried (http://www.ladyada.net)
example added 9 Jul 2009
by Tom Igoe
modified 22 Nov 2010
by Tom Igoe
modified 7 Nov 2016
by Arturo Guadalupi
*/
// include the library code:
#include <LiquidCrystal.h>
// initialize the library by associating any needed LCD interface pin
// with the arduino pin number it is connected to
const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2, button = 8;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);
void setup() {
// set up the LCD's number of columns and rows:
pinMode(button, INPUT);
}
void loop() {
if (digitalRead(button) == HIGH) {
lcd.begin(16,2);
lcd.print("don't touch me!");
} else {
lcd.noDisplay();
}
}
I am running on an Arduino Uno. Everything works fine, I even use a 10k resistor between the button and the ground. What can I do to stop the flickering?