Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

change keypad from port d to port c

Status
Not open for further replies.

iedchan

Newbie level 1
Joined
Jun 2, 2007
Messages
1
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,286
anyone knows how to change this coding so that i could use port c instead of port d for the keypad interface with pic16f877


Code:
//#byte port_d = 0x08
char get_key(void)
{
   char t;
      while (1) {
      output_d (input_d() | 0xFF);

       output_bit(PIN_D4,0);
       if (input (PIN_D0) ==0);{
            delay_ms(10);
               return 'A';
      }
      if (input (PIN_D1) ==0){
             delay_ms(10);
                return '7';
      }

      if (input (PIN_D2) ==0){
             delay_ms(10);
                return '4';
      }
      if (input (PIN_D3) ==0){
             delay_ms(10);
                return '1';
      }
      output_d (input_d() | 0xFF);

      output_bit(PIN_D5,0);
       if (input (PIN_D0) ==0);{
            delay_ms(10);
               return '0';
       }
       if (input (PIN_D1) ==0){
             delay_ms(10);
                return '8';
       }
       if (input (PIN_D2) ==0){
             delay_ms(10);
                return '5';
      }
      if (input (PIN_D3) ==0){
             delay_ms(10);
                return '2';
      }
      output_d (input_d() | 0xFF);

      output_bit(PIN_D6,0);
       if (input (PIN_D0) ==0);{
            delay_ms(10);
               return 'B';
       }
       if (input (PIN_D1) ==0){
             delay_ms(10);
                return '9';
       }
       if (input (PIN_D2) ==0){
             delay_ms(10);
                return '6';
       }
       if (input (PIN_D3) ==0){
             delay_ms(10);
                return '3';
       }
       output_d (input_d() | 0xFF);

      output_bit(PIN_D7,0);
       if (input (PIN_D0) ==0);{
            delay_ms(10);
               return 'C';
       }
       if (input (PIN_D1) ==0){
             delay_ms(10);
                return 'D';
       }
       if (input (PIN_D2) ==0){
             delay_ms(10);
                return 'E';
       }
       if (input (PIN_D3) ==0){
             delay_ms(10);
                return 'F';
       }
       else return '<';
      }
}
 

There are some more codes related to this where in u need to make the change.Get the complete program.

Cheers!
 

can you attach the schematic? it should be useful,

and, its CCS so... you should change all PIN_Dx to PIN_Cx, all the output_d to output_c and the same with input_d to input_c...
also... if you are using fast_io(D) somewhere in the code, change it to fast_io(C)....

I think it'll do the job...
 

Status
Not open for further replies.

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top