EngineersGarage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise
You are here: Home / Topics / 4×4 Keypad Debounce

4×4 Keypad Debounce

|

Microcontroller › AVR › 4×4 Keypad Debounce

  • This topic has 2 replies, 2 voices, and was last updated 10 years, 11 months ago by Setebwer.
Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • June 15, 2015 at 7:21 am #3713
    Setebwer
    Participant

    Hello. I'd need some help with debouncing a keypad.

    KEYPAD_DDR = DDRC

    KEYPAD_PORT = PORTC

    I've tried debouncing number 0 in 29th line but It doesn't work.

    Can someone help me out please?

    Cheers,

    #define F_CPU 3686400UL
    #define PERGES 300 //Pergesmentesiteshez

    #include<avr/io.h>
    #include<util/delay.h>
    #include"keypad.h"
    #include"lcd.h"

    int main(void)
    {

        KEYPAD_DDR=0b00001111; //upper 4 bits are declared input and lower 4 bits are declared output(4×4 Keypad is connected)    
        KEYPAD_PORT=0b11111111;//lower 4 bits are given high value and pull-up are enabled for upper 4 bits
        
        lcd_init();
        
        unsigned char keypad;

        while(1)
        {    
            //prints("hello");
            
            keypad=keypad_beolvas();

            if(keypad!=0xff)
            {
                switch(keypad)
                {
                    case 0: while(!(KEYPAD_PIN & (1<<PC4))) ;
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("0");
                            break;
                    case 1:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("1");
                            break;
                    case 2:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("2");
                            break;
                    case 3:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("3");
                            break;
                    case 4:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("4");
                            break;
                    case 5:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("5");
                            break;
                    case 6:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("6");
                            break;
                    case 7:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("7");
                            break;
                    case 8:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("8");
                            break;
                    case 9:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("9");
                            break;
                    case 10:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("*");
                            break;
                    case 11:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("#");
                            break;
                    case 12:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("A");
                            break;
                    case 13:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("B");
                            break;
                    case 14:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("C");
                            break;
                    case 15:
                            _delay_ms(PERGES);    //pergés mentesítés
                            prints("D");
                            break;
                }
            }
        }
        return 0;
    }

    June 17, 2015 at 6:51 am #12991
    Ashutosh Bhatt
    Participant

    pls clerify your question? what is problem?  

    June 18, 2015 at 7:31 am #12999
    Setebwer
    Participant

    My goal is to do software debounce. I've made this code that's working only for * 0 # D buttons. So while I'm pushing * MCU is waiting. How should I modify this code for debouncing 1, 2 ,3, 4, 5, 6, 7, 8, 9, A, B, C buttons as well?

    int main(void)

    {

    while(1)

    {

    …

    if(keypad==0) // When zero is pushed…

    {

    while(!(PINC&(1<<PC5))); //Waiting while zero is pushed

    _delay_ms(50);

    }

    }

     

    }

    My 4×4 keypad hardware connections to AVR

    DDRC=0b00001111; //upper 4 bits are declared input and lower 4 bits are declared output(4×4 Keypad is connected)    
    PORTC=0b11111111;//lower 4 bits are given high value and pull-up are enabled for upper 4 bits

  • Author
    Posts
Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.
Log In

RSS Recent Posts

  • reviving old swordfish program but? May 17, 2026
  • Assistance locating a 'trail' camera gadget, please ? May 16, 2026
  • Analog multiplexer has gone obselete May 16, 2026
  • Difference between TTL, RS232 and RS485 May 16, 2026
  • Smart Buoy project May 16, 2026

Stay Up To Date

Newsletter Signup
EngineersGarage

Copyright © 2026 WTWH Media LLC. All Rights Reserved. The material on this site may not be reproduced, distributed, transmitted, cached or otherwise used, except with the prior written permission of WTWH Media
Privacy Policy | Advertising | About Us

Search Engineers Garage

  • Engineers Garage Main Site
  • Visit our active EE Forums
    • EDABoard.com
    • Electro-Tech-Online
  • Projects & Tutorials
    • Circuits
    • Electronic Projects
    • Tutorials
    • Components
  • Digi-Key Store
    • Cables, Wires
    • Connectors, Interconnect
    • Discrete
    • Electromechanical
    • Embedded Computers
    • Enclosures, Hardware, Office
    • Integrated Circuits (ICs)
    • Isolators
    • LED/Optoelectronics
    • Passive
    • Power, Circuit Protection
    • Programmers
    • RF, Wireless
    • Semiconductors
    • Sensors, Transducers
    • Test Products
    • Tools
  • Advertise