lordgarth6
Newbie level 4
- Joined
- Apr 25, 2012
- Messages
- 5
- Helped
- 0
- Reputation
- 0
- Reaction score
- 0
- Trophy points
- 1,281
- Activity points
- 1,332
i cant seem to get this keypad to work with a pic 16F1937 on portD using any code that isnt made by 'flowcode' software package or are test routines
http://www.matrixmultimedia.com/resources/files/datasheets/EB014-30-1.pdf for data sheet on my keypad that is an 'E-block' module and how it is wired
http://www.matrixmultimedia.com/resources/files/datasheets/EB014-30-1.pdf for data sheet on my keypad that is an 'E-block' module and how it is wired
Code C - [expand] 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 // 3x4 Keypad with PIC 16F1937 in MikroC #include"7_seg_Lib.h" const char Column[5]={0x10,0x20,0x40,0x80}; void main() { char Keypad=255,x=0; TRISB=0x00; // 7 seg output setup PORTB=0xFF; // 7 seg initial output TRISD=0xF0; // keypad i/o setup b0-3 input b4-7 output PORTD=0x00; // keypad initial output while(1) { Delay_ms(100); for(x=0;x<4;x++){ // loop PORTD=Column[x]; // change column output if(PORTD.B0==1){ // if column 1 is high if(PORTD.B4==1) Keypad=1; // if row 1 is high else if(PORTD.B5==1) Keypad=4; // if row 2 is high else if(PORTD.B6==1) Keypad=7; // if row 3 is high else Keypad=0x2A; // * default } else if(PORTD.B1==1){ // if column 2 is high if(PORTD.B4==1) Keypad=2; // if row 1 is high else if(PORTD.B5==1) Keypad=5; // if row 2 is high else if(PORTD.B6==1) Keypad=8; // if row 3 is high else Keypad=0; // default } else if(PORTD.B2==1){ // if column 3 is high if(PORTD.B4==1) Keypad=2; // if row 1 is high else if(PORTD.B5==1) Keypad=6; // if row 2 is high else if(PORTD.B6==1) Keypad=9; // if row 3 is high else Keypad=0x23; // # default } else Keypad=255; // default value } if(Keypad==255) Keypad='G'; // to test if it was my 7 seg code rthat was wrong PORTB=output_seg('a',4,Keypad); // output to 7 seg } }