Connect with us

Keypad Using Arduino

Discussion in 'Microcontrollers, Programming and IoT' started by pavankukkala, Dec 18, 2015.

Scroll to continue with content
  1. pavankukkala

    pavankukkala

    78
    0
    Mar 25, 2014
    Hi friends,
    I have been using the 4x4 keypad interfacing with arduino I have written code .
    It is working fine
    When I am pressing the 2 it is printing 4 i.e interchanging of rows and columns.
    I will give u the code can anybody solve this problem
    I have a project on this.

    #include <Keypad.h>

    const byte ROWS = 4; // Four rows
    const byte COLS = 4; // Three columns
    // Define the Keymap
    char keys[ROWS][COLS] = {
    {'1','2','3','A'},
    {'4','5','6','B'},
    {'7','8','9','C'},
    {'#','0','*','D'}
    };

    // Connect keypad ROW0, ROW1, ROW2 and ROW3 to these Arduino pins.
    byte rowPins[ROWS] = { 5, 4, 3, 2 };
    // Connect keypad COL0, COL1 and COL2 to these Arduino pins.
    byte colPins[COLS] = { 9, 8, 7, 6 };

    // Create the Keypad
    Keypad keypad = Keypad( makeKeymap(keys), rowPins, colPins, ROWS, COLS );

    void setup()
    {
    Serial.begin(9600);
    }


    void loop(){
    char key = keypad.getKey();
    if (key){
    Serial.println(key);
    }
    }
     
  2. Harald Kapp

    Harald Kapp Moderator Moderator

    10,025
    2,138
    Nov 17, 2011
    You should be able to solve this yourself. Just swap the characters in the keymap array, putting the 2 where the 4 is.
     
  3. pavankukkala

    pavankukkala

    78
    0
    Mar 25, 2014
    Thanks Dude
     
Ask a Question
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.
Electronics Point Logo
Continue to site
Quote of the day

-