×

With the recent surge in Omicron cases, shipping may be slower than stated times. We are working to build, ship and respond to everything as quickly as possible. Please see all COVID-19 updates here. Thank you for your continued support.

Member #559646

Member Since: June 2, 2014

Country: United States

  • ,i have an arduino + lcd keypad and i want to put a function in a case menu but i dont know how .th function must count how many times i push a button in a period of time.i use pin 2 and 3 for buton.if somebody can help me with the cod.

  • hi everyone ,i have an arduino + lcd keypad and i want to put a function in a case menu but i dont know how .th function must count how many times i push a button in a period of time.i use pin 2 and 3 for buton.if somebody can help me with the cod.

    my menu cod is this:

    include <LiquidCrystal.h>

    // Initialize the library with the numbers of the interface pins LiquidCrystal lcd(8, 9, 4, 5, 6, 7);

    //States for the menu. int currentMenuItem = 0; int lastState = 0;

    void setup() { //Set the characters and column numbers. lcd.begin(16, 2); //Print default title. clearPrintTitle(); }

    void loop() { //Call the main menu. mainMenu(); }

    void mainMenu() { //State = 0 every loop cycle. int state = 0; //Refresh the button pressed. int x = analogRead (0); //Set the Row 0, Col 0 position. lcd.setCursor(0,0);

    //Check analog values from LCD Keypad Shield if (x < 100) { //Right } else if (x < 200) { //Up state = 1; } else if (x < 400){ //Down state = 2; } else if (x < 600){ //Left } else if (x < 800){ //Select state = 3; }

    //If we are out of bounds on th menu then reset it. if (currentMenuItem < 0 || currentMenuItem > 4) { currentMenuItem = 0; }

    //If we have changed Index, saves re-draws. if (state != lastState) { if (state == 1) { //If Up currentMenuItem = currentMenuItem - 1; displayMenu(currentMenuItem); } else if (state == 2) { //If Down currentMenuItem = currentMenuItem + 1;
    displayMenu(currentMenuItem); } else if (state == 3) { //If Selected selectMenu(currentMenuItem); } //Save the last State to compare. lastState = state; } //Small delay delay(5); }

    //Display Menu Option based on Index. void displayMenu(int x) { switch (x) { case 1: clearPrintTitle(); lcd.print ("->TESTARE BATRANI"); break; case 2: clearPrintTitle(); lcd.print ("->TESTARE TINERI"); break; case 3: clearPrintTitle(); lcd.print ("->TESTARE COPII"); break; } }

    //Print a basic header on Row 1. void clearPrintTitle() { lcd.clear(); lcd.setCursor(0,0); lcd.print("MENU TESTER"); lcd.setCursor(0,1); }

    //Show the selection on Screen. void selectMenu(int x) { switch (x) { case 1: clearPrintTitle(); lcd.print ("Selectat TEST BATRANI"); //Call the function that belongs to Option 1 break; case 2: clearPrintTitle(); lcd.print ("Selectat TEST TINERI"); //Call the function that belongs to Option 2 break; case 3: clearPrintTitle(); lcd.print ("Selectat TEST COPII"); //Call the function that belongs to Option 3 break; } }

No public wish lists :(