Arduino Lcd Counter

29,723

11

5

build a simple arduino lcd counter using simple components such as push buttons and LCD

Teacher Notes

Teachers! Did you use this instructable in your classroom?
Add a Teacher Note to share how you incorporated it into your lesson.

Step 1: 1

build a simple arduino lcd counter using simple components such as push buttons and LCD

The parts list

Arduino Uno

16x2 LCD

Push Buttons

Potentiometer 100k

10k Resistor

220R Resistor

Breadboard

Connecting Wires

Step 2: Circuit

Step 3: Code

Be the First to Share

    Recommendations

    • CNC Contest

      CNC Contest
    • Make it Move

      Make it Move
    • Teacher Contest

      Teacher Contest

    5 Discussions

    0
    None
    mauro.malatestarLAsugar666

    Reply 5 months ago

    Check my reply above, you can ignore the AND logic inside the loop:

    if (buttonState == HIGH) {
    // if the current state is HIGH then the button went from off to on:

    It will increase whenever state changes

    0
    None
    AissaniA

    11 months ago

    hello,

    that was nice except for the fact , if you press the button for a long time it will continuously counting up every 200mS, without releasing the button and pressing again, any idea to fix that please? i want it to stop counting unless the button is released and pressed again what ever is the pressing time is,

    thankyou in advance

    1 reply
    0
    None
    mauro.malatestaAissaniA

    Reply 5 months ago

    Hello, I don't know if you managed to solve this issue, but you can use a State Change detection. I've have modified the code available at: https://www.arduino.cc/en/Tutorial/StateChangeDetection

    Here's mine:

    int buttonPushCounter = 0; // counter for the number of button presses
    int buttonState = 0; // current state of the button
    int lastButtonState = 0; // previous state of the button
    const int buttonPin = 7; // the pin that the pushbutton is attached to


    void loop() {
    // read the pushbutton input pin:
    buttonState = digitalRead(buttonPin);
    // compare the buttonState to its previous state
    if (buttonState != lastButtonState) {
    // if the state has changed, increment the counter
    if (buttonState == HIGH) {
    // if the current state is HIGH then the button went from off to on:
    buttonPushCounter++;
    }
    // Delay a little bit to avoid bouncing
    delay(50);
    lcd.setCursor(3, 1);
    lcd.print(buttonPushCounter);
    }
    // save the current state as the last state, for next time through the loop
    lastButtonState = buttonState;
    }

    0
    None
    DennisPropellerHead

    2 years ago

    Can you help me expand this idea a bit? I want to build a punch counter for my son's martial arts club. It will count the number of hits to a punching board (bag) in 45 seconds.

    Ideally, what I envision is a reset button, triggering a set of warning beeps......

    beep, beep, beeeeeeeeeeeeeep, a small counting display 1-45 seconds and a much larger display for the count (3 digits would suffice) followed by a long beep and stop and freeze the count until the next reset.

    Although it might be possible to trigger it with a switch, I think an accelerometer might be the way to go.

    I have all the parts to build, but I am a complete beginner on the programming side and I could use some help. I want to learn this stuff, but I need this project sooner than later. ;-)

    Any offers to help greatly appreciated!

    Best Regards, Dennis