Trouble incrementing counter with pushbutton on lcd - 1602A - need help wiring

Hello,

this is my first post on the arduino forum. I'm having issues with a personal project and need some guidance, specifically about wiring.

I'm trying to increment a number on the lcd with a pushbutton. Pushing the button currently results in either incrementing correctly and the screen dimming and going blank while pushing / or the screen dimming and going blank, and not showing anything afterwards.

Either way the screen shouldn't dim and it shouldn't remove the characters while pushing. It should only increment the number when the button is pushed and released.

this is my current setup, lcd functioning: (my biggest apology in advance for the unclear wiring, I am a rookie and don't really have the good knowledge and materials for working properly yet)

I use 1 jumper from arduino 5V to the breadboard, powering the lcd and the button, ditto with the ground.

However, I feel like I wired the button wrong, causing the screen to dim/go blank and 80% of the time not incrementing and leaving the screen blank.

my code uploaded:

#include <LiquidCrystal.h> //Library LiquidCrystal

const int rs = 12, en = 11, d4 = 5, d5 = 4, d6 = 3, d7 = 2;
LiquidCrystal lcd(rs, en, d4, d5, d6, d7);

const int Up_buttonPin = 7;

int buttonPushCounter = 0; // counter for the number of button presses
int up_buttonState = 0; // current state of the up button
int up_lastButtonState = 0; // previous state of the up button

bool bPress = false;

void setup()
{
Serial.begin(9600);
pinMode( Up_buttonPin , INPUT_PULLUP);
lcd.begin(16, 2);
lcd.setCursor(0, 0);
lcd.print("Counter Value:");
lcd.setCursor(2, 1);
lcd.print(buttonPushCounter);
}
void loop()
{
checkUp();

if ( bPress)
{
bPress = false;
lcd.setCursor(2, 1);
lcd.print(" ");
lcd.setCursor(2, 1);
lcd.print(buttonPushCounter);
}
}
void checkUp()
{
up_buttonState = digitalRead(Up_buttonPin);
if (up_buttonState != up_lastButtonState) // compare the buttonState to its previous state
{
if (up_buttonState == LOW) // if the state has changed, increment the counter
{
bPress = true; // if the current state is HIGH then the button went from off to on:
buttonPushCounter++;
Serial.println("on");
Serial.print("number of button pushes: ");
Serial.println(buttonPushCounter);
}
else {
Serial.println("off"); // if the current state is LOW then the button went from on to off:
}
delay(50); // Delay a little bit to avoid bouncing
}

up_lastButtonState = up_buttonState; // save the current state as the last state, for next time through the loop
}

Thanks,
Arthur

Have You heard about debouncing buttons? Check that!
Provide a proper wiring. That's a birdnest.

Hi, thanks for the quick reply!

I'm sorry but there's not enough time for me to do a proper wiring for this project, as it is due for tomorrow. I struggled a lot the past days trying to make the lcd screen work, since I have poor jumper cables. I soldered these on as well, since the holes are too large on the lcd and I don't have pin headers to solder them on to the lcd.

I completely understand if it's difficult for you to identify the problem with messy wiring, but I don't have a choice at this point. I enjoy Arduino, but I don't have sufficient time and tools.

Correct me if I'm wrong, but doesn't debouncing buttons lay in the code part only? Because I think my code does take care of bouncing. Or is this a wiring thing as well?

Arthur

Not a bad first effort for picture posting.

It's difficult to distinguish which jumpers go to which pins on the Arduino and the display. Can you put up another picture, or pictures, clearly showing the individual connections? Maybe tease out the ends a bit to separate them and remove the overlap/twisting entry. An angled shot vs. straight down may help with this, too.

arthurrobaeys:
I'm sorry but there's not enough time for me to do a proper wiring for this project, as it is due for tomorrow. I

If you don't have time to do t right, how will you find time to do it again?

That pulldown resistor you have for your button looks like blue-black-black-silver which is a very small resistor. How many ohms is that? You are probably pulling way to much current when you push the button. Re-wire your button so one side is ground and the other goes to your arduino pin. Change the pin from INPUT to INPUT_PULLUP and then reverse your logic (HIGH = not pushed, LOW = pushed)

The resistor is indeed only 10 ohm’s if i’m right. I will try to post clearer pictures tomorrow. I did find something interesting though. When i wiggled the jumper that gives ground to the breadboard and thus to the lcd and button, the counter went up. So I figured that the ground connection disrupted the button. I gave the one side of the button its own ground port in the arduino and the vcc to 3.3V. Now it increments like it should without disrupting the lcd. However, I would like to free the 3.3V port, because I want to use it for wiring another sensor. How do I split the 5V and the ground with the lcd and the button, so they don’t interfere with each other? I thought creating a sort of rail with the arduino and breadboard would pass the current along nicely, but I don’t know enough of circuits and electronics.

Arthur

Breadboards are notoriously flakey. Your intention of creating a rail on the breadboard is good, but the breadboard is not. Your resistor associated with your pushbutton should be more like 10K or more. At 10 ohms, 5V/10 ohms = 500 mA but your arduino can NOT supply that much current. Better yet, take my suggestion in reply #4 and get rid of that resistor.

Remove the connection from the potentiometer to 5 V. You will find it easier to set the contrast.