G
G
georgich2014-01-19 11:34:25
Arduino
georgich, 2014-01-19 11:34:25

Working with the clock button on the Arduino

Greetings.
I connect the button for work to the project. Used the Bounce library version 2 to prevent bounce. Here is the code:

#define BUTTON_ENTER 13
Bounce buttonEnter = Bounce();

void setup()
{
  pinMode(BUTTON_ENTER, INPUT);
  buttonEnter.attach(BUTTON_ENTER);
  buttonEnter.interval(5);
}

void loop()
{
  switch(mainMenu)
  {
    case(1):

    break;

    case(2):

    break;

    case(3):
    display_lcd(0,0,"Ololo");
    delay (1000);
    lcd.clear();
    mainMenu = 0;
    break;

  default:
     if (buttonEnter.update())
    {
      if (buttonEnter.read() == HIGH) {
         mainMenu = 3;
       }
    }
    break;
  }
}

I connected, as can be seen from the code, to pin 13, on which the LED sits, located by default on the Arduino Uno board. The button is connected according to this scheme: arduino.ru/tutorials/button through a 10 kΩ resistor. When you press the button, the LED, which is located on the board, lights up immediately, but the inscription on the screen appears after about 2 seconds of holding the button. I would like the inscription to appear faster. What am I doing wrong?
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
georgich, 2015-01-24
@georgich

Here is the answer to my question: www.youtube.com/watch?v=_LCCGFSMOr4
No more guessing guys!

V
vanyamba-electronics, 2015-01-04
@vanyamba-electronics

Apparently there is an error in the diagram. You need a resistor not to D13, but to the adjacent GND.
Example_button_scheme-350x300.png

A
andjel, 2015-01-22
@andjel

Your best bet is to omit delay() in your code and use this .
Most likely, it affects the work of the Bounce library.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question