connecting a 4x3 keypad to pic16f877a

Discussion about projects that used PIC Microcontroller, Hardware Interface, Programming Algorithm and etc......

connecting a 4x3 keypad to pic16f877a

Postby altron11 » Thu Sep 22, 2011 12:11 am

Hi, i need to connect a 4x3 keypad to pic16f877a. I am connecting it to Port C as i had used Port B for other outputs. i go through some tutorials and even look through PR9B. I though we need to connect pullup resistors to the rows, but what i saw some proj was connect to the column instead. I am rather confused on this, can you help me on this? I had already solder 10k resistors to the rows and intend to connect directly to the port C. Is this correct too?
Attachments
Keypad.jpg
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Re: connecting a 4x3 keypad to pic16f877a

Postby ober » Thu Sep 22, 2011 12:32 pm

You can actually refer to the interface and program of PR9-B, though it is using 4x4 matrix, the concept is the same, you will need to study the program and connection.
Ober Choo
Cytron Technologies Sdn Bhd
www.cytron.com.my
User avatar
ober
Moderator
 
Posts: 1486
Joined: Wed Apr 15, 2009 1:03 pm

Re: connecting a 4x3 keypad to pic16f877a

Postby shahrul » Fri Sep 23, 2011 10:37 am

This is my 4X4 keypad lesson. Source code and video.
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: connecting a 4x3 keypad to pic16f877a

Postby altron11 » Sun Oct 02, 2011 11:33 pm

Hi Ober and sharul,

Thanks for the advises and help.

I managed to get the keypad working. now i need to keyin the values and compare it against the readings measured from a sensor. But i am unable to display the keyin values and compare against the sensor reading. Would need your help on this.
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Re: connecting a 4x3 keypad to pic16f877a

Postby shahrul » Sun Oct 02, 2011 11:56 pm

altron11 WROTE:Hi Ober and sharul,

Thanks for the advises and help.

I managed to get the keypad working. now i need to keyin the values and compare it against the readings measured from a sensor. But i am unable to display the keyin values and compare against the sensor reading. Would need your help on this.

How you show the keypad working? You show on 7 segment or LCD?
User avatar
shahrul
Professional
 
Posts: 812
Joined: Sat May 16, 2009 9:54 pm
Location: Selangor

Re: connecting a 4x3 keypad to pic16f877a

Postby altron11 » Mon Oct 03, 2011 12:19 am

shahrul WROTE:
altron11 WROTE:Hi Ober and sharul,

Thanks for the advises and help.

I managed to get the keypad working. now i need to keyin the values and compare it against the readings measured from a sensor. But i am unable to display the keyin values and compare against the sensor reading. Would need your help on this.

How you show the keypad working? You show on 7 segment or LCD?


hi shahrul,

i display on lcd. i used the codes from PR9B. i managed to get it to display but when i try intergate the codes with my sensors, it cannot display after i key in.
altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm

Re: connecting a 4x3 keypad to pic16f877a

Postby yonghui » Mon Oct 03, 2011 10:02 am

hi,

i think u will need to sharing portion of of code,

mayb u have some clear lcd function in an infinite loop that continuously clear the lcd after u display the char u wanted, try to debug that.
for example:

CODE: SELECT_ALL_CODE
while(1)
{

  lcdclear(); // lcd clear function

  lcddispstring( " hello world");  // display a string to lcd


/*some other functions of keypad*/

}



this will cause the lcd to be cleared every time after u display it onto lcd.


is this happen to ur code? or something similar?


or pls do make sure that the program does not hang after goes into ur keypad function.
try to debug with lighting LED on and off after goes out from the keypad funtion.




regards,
yonghui
thanks&regards,
yh
yonghui
Professional
 
Posts: 732
Joined: Mon Sep 28, 2009 3:27 pm

Re: connecting a 4x3 keypad to pic16f877a

Postby altron11 » Thu Oct 06, 2011 12:54 am

yonghui WROTE:hi,

i think u will need to sharing portion of of code,

mayb u have some clear lcd function in an infinite loop that continuously clear the lcd after u display the char u wanted, try to debug that.
for example:

CODE: SELECT_ALL_CODE
while(1)
{

  lcdclear(); // lcd clear function

  lcddispstring( " hello world");  // display a string to lcd


/*some other functions of keypad*/

}



this will cause the lcd to be cleared every time after u display it onto lcd.


is this happen to ur code? or something similar?


or pls do make sure that the program does not hang after goes into ur keypad function.
try to debug with lighting LED on and off after goes out from the keypad funtion.




regards,
yonghui

Hi YongHui,

I managed to solve the problem. I can display a string to request keyin. then display. 1 minor problem i faced is that i am unable to show the 2nd number when key and it jumps to display.
Do i need to add some delay?

As follow would be the portion of the code.
CODE: SELECT_ALL_CODE
lcd_clr();                     //clear LCD
   delay(1000);                  //delay
   lcd_goto(0);                  //initial display
   send_string("PLEASE ENTER");      //Display "PLEASE ENTER" on lcd
   lcd_goto(20);                  //Display on 2nd line
   send_string("2 DIGIT SPEC");
   
   while(1)
   {      //keypad scanning
         clearrow1();                  //Clear 1st output pin and set the others
         scancolumn1();                  //scan column 1-4
         clearrow2();                  //Clear 2nd output pin and set the others
         scancolumn2();                  //scan column
         clearrow3();                  //Clear 3rd output pin and set the others
         scancolumn3();                  //scan column
         clearrow4();                  //Clear 4th output pin and set the others
         scancolumn4();                  //scan column
   
         if(num_count==2)
      {
         delay(8000);
         //while(1)               
         //{
            //lcd_clr();      
            lcd_goto(0);            //cursor start from beginning
      
            //display character on LCD
            send_char(' ');
            send_char('S');
            send_char('P');
            send_char('E');
            send_char('C');
            send_char('.');
            send_char('.');
            send_char('=');
   
            lcd_goto(20);               //cursor go to 2nd line of the LCD

            //display character on LCD
            send_char(' ');
            send_char('M');
            send_char('E');
            send_char('A');
            send_char('S');
            send_char('U');
            send_char('R');
            send_char('E');
            send_char('D');
            send_char('=');

altron11
Newbie
 
Posts: 14
Joined: Tue Aug 30, 2011 12:20 pm


Return to PIC Microcontroller

Who is online

Users browsing this forum: No registered users and 4 guests