Again great video with great explanation keep uploading such a valuable learning videos
@StudentCompanion
9 жыл бұрын
Faizan Qureshi Thanks.
@keshenanaidu7160
9 жыл бұрын
Very nice tutorial. Very easy to understand. Thank you very much for these great tutorials.
@FloppyEmulatorPicF
4 жыл бұрын
very good
@StudentCompanion
4 жыл бұрын
Thank you.
@kshitijvengurlekar1192
5 жыл бұрын
Thanks a lot dude, I love you
@StudentCompanion
5 жыл бұрын
You are welcome!
@wisdom_wellness365
3 жыл бұрын
Very nice! I like it!
@StudentCompanion
3 жыл бұрын
Thanks for your feedback.
@setsutsubasa8742
7 жыл бұрын
Hi. Your video has helped me understand the basic logic of how keypad interfacing works. I am interfacing LCD and 3x4 matrix keypad with PIC18F4550 microcontroller. I am using MPLABX, XC8 with PICkit3. I am using C language. I am facing trouble trouble with 1. Not able to print the right pin number on the screen. eg. if I press key 1, there is nothing on the display and if I press 5 then it displays * on the screen. 2. Writing interrupt or code to wait for a keystroke. NB: I am using internal pull up at portB, external oscillator of 20MHz frequency. My code is: #include #include #include #include "delays.h" //--- for delays #include "xlcd.h" /* * */ #pragma config PLLDIV = 5 // PLL Prescaler Selection bits (Divide by 5 (20 MHz oscillator input)) #pragma config CPUDIV = OSC1_PLL2// System Clock Postscaler Selection bits ([Primary Oscillator Src: /1][96 MHz PLL Src: /2]) #pragma config USBDIV = 2 // USB Clock Selection bit (used in Full-Speed USB mode only; UCFG:FSEN = 1) (USB clock source comes from the 96 MHz PLL divided by 2) #pragma config FOSC = HSPLL_HS // Oscillator Selection bits (HS oscillator (HS) #pragma config LVP = OFF //low voltage programming disabled #pragma config FCMEN = OFF #pragma config BORV = 3 #pragma config WDT = OFF #pragma config CPB = OFF void LCD_init (void); //--- To Initialise LCD display void LCD_Clear (void); //--- To clear the display void DelayFor18TCY (void); //--- For 18 instruction cycle delay void DelayPORXLCD(void); //--- For 200 millisecond delay which is more than the minimum as per LCD datasheet void DelayXLCD(void); //--- For void Delay_s(unsigned int); /********************************* Macro Defination ******************************/ #define line_1 0x00 #define line_2 0x40 #define clear 0x01 void main (void) { unsigned char rows[3]; TRISB = 0xFF ; //set all pins as inputs to start with ADCON1 = 0x0F; //set all PORTB pins to digital mode. INTCON2bits.NOT_RBPU = 0; //Pull up enable C1_DAT = 0; //so we can drive COL1 low later C2_DAT = 0; //so we can drive COL2 low later C3_DAT = 0; //so we can drive COL3 low later //ADC_init(); //--- Initialise ADC DelayPORXLCD(); //--- 20 ms delay after VDD > 4.5V LCD_init(); //--- Initialise LCD DelayXLCD(); //--- 10 ms delay LCD_Clear (); //--- Clear LCD display DelayXLCD(); DelayXLCD(); putrsXLCD("Welcome. Press a"); DelayXLCD(); SetDDRamAddr(line_2); //Shift cursor to beginning of 2nd line DelayXLCD(); putrsXLCD("keypad key"); for (int f = 0; f 4.5V { Delay1KTCYx (100); //--- For 20 MHz CLK, 1 instruction cyc = 0.2us => 100k*0.2u=200ms // return 0; } void DelayXLCD () //--- For more 5ms delay after VDD>4.5V { Delay1KTCYx (50); //--- For 20 MHz CLK, 1 instruction cyc = 0.2us => 50k*0.2u=100ms } void Delay_s (unsigned int time) //--- For time second delay { Delay1KTCYx (time); //--- For 20 MHz CLK, 1 instruction cyc = 0.2us => time*0.2u }
@setsutsubasa8742
7 жыл бұрын
My idea is to use three pins to drive the three columns, but only set one at a time to be an output, driving low. The other two would be set to input mode so they can float and that is how I can select one column at a time. The four rows are connected to pull up resistors.I am using a 3 byte array rows which will fill the state of all the buttons.A pressed button will give a 0 bit, and an unpressed button will give a 1.
@StudentCompanion
7 жыл бұрын
Can you post your schematic diagram?
@setsutsubasa8742
7 жыл бұрын
Sure. i64.tinypic.com/25kioes.png I have updated the code as well. I am getting a different error now. The error is if I press any of 2580 I get the whole row printed eg. if I press 2, the output is 1 2 if I press 3, output is 123 as infinite loop.
@setsutsubasa8742
7 жыл бұрын
UPDATED CODE: #define C1_DAT LATBbits.LATB4 //Column 1 is set portB4 as output #define C2_DAT LATBbits.LATB5 //Column 2 is set portB5 as output #define C3_DAT LATBbits.LATB6 //Column 3 is set portB6 as output #define C1_DIR TRISBbits.TRISB4 //Column 1 is set portB4 as output #define C2_DIR TRISBbits.TRISB5 //Column 2 is set portB5 as output #define C3_DIR TRISBbits.TRISB6 //Column 3 is set portB6 as output #define R1 PORTBbits.RB3 #define R2 PORTBbits.RB2 #define R3 PORTBbits.RB1 #define R4 PORTBbits.RB0 void LCD_init (void); //--- To Initialise LCD display void LCD_Clear (void); //--- To clear the display void DelayFor18TCY (void); //--- For 18 instruction cycle delay void DelayPORXLCD(void); //--- For 200 millisecond delay which is more than the minimum as per LCD datasheet void DelayXLCD(void); //--- For void Delay_s(unsigned int); /********************************* Macro Defination ******************************/ #define line_1 0x00 #define line_2 0x40 #define clear 0x01 void main (void) { unsigned char Col[3]; TRISB = 0xFF ; //--- set all pins as inputs to start with ADCON1 = 0x0F; //--- set all PORTB pins to digital mode. INTCON2bits.NOT_RBPU = 0; //--- Pull up enable INTCONbits.GIE = 1; //--- Enable global interrupt C1_DAT = 0; //--- So COL1 could be drived low later C2_DAT = 0; //--- So COL2 could be drived low later C3_DAT = 0; //--- So COL3 could be drived low later DelayPORXLCD(); //--- 20 ms delay after VDD > 4.5V LCD_init(); //--- Initialise LCD DelayXLCD(); //--- 10 ms delay LCD_Clear (); //--- Clear LCD display DelayXLCD(); DelayXLCD(); putrsXLCD("Welcome. Press a"); DelayXLCD(); SetDDRamAddr(line_2); //Shift cursor to beginning of 2nd line DelayXLCD(); putrsXLCD("keypad key"); for (int f = 0; f
@miracleobiano1825
5 жыл бұрын
Why using INTCON2bits.NOT_RBPU instead of INTCON2bits.RBPU? What's the essence of NOT?
@StudentCompanion
5 жыл бұрын
Hi, INTCON2bits.NOT_RBPU is to disable the internal pull-up resistors because we are using external resistors on the switch, INTCON2bits.RBPU is to enable those pull-up resistors which we don't want in this case.
@miracleobiano1825
5 жыл бұрын
Okay. Thanks
@StudentCompanion
5 жыл бұрын
You are welcome!
@andoencomby1
2 жыл бұрын
Hi, how can i get the "config. C" library?
@htunlin1876
7 жыл бұрын
I want to know can be use only one key to show in LCD.For example when I press one time to the number 1 key, LCD show 1. Press two times only to the number 1 key and then LCD show 2. Press three times and show 3 and so on.I want to use only one key . Please answer me Sir!
@StudentCompanion
7 жыл бұрын
+Htun Lin watch this video: kzitem.info/news/bejne/xIafzXWlop-hi20
@htunlin1876
7 жыл бұрын
thanks you sir !
@StudentCompanion
7 жыл бұрын
+Htun Lin you are welcome!
@NikhilHande030490
8 жыл бұрын
what does 0xFF used for in keypadmatrix array?
@StudentCompanion
8 жыл бұрын
The 0xFF is just a number returned when no key was pressed.
@tgseetoh
4 жыл бұрын
sir, is it possible to interface a keypad to a PIC micro controller but display the results onto a lcd instead of a 7 segment display?
@StudentCompanion
4 жыл бұрын
Yes. You don't have to use the 7 segment display. Watch this video part1 to part3 we explained how you can do it: kzitem.info/news/bejne/pHljr56MjZ-ZnXY
@dbrezzy4957
7 жыл бұрын
in the Matric Array code for the keypad arrangement... what is the function of "0xFF" added at the end.... ???
@StudentCompanion
7 жыл бұрын
Temitayo Abel you can remove it then you'll see the effects.
@the0sea0emperor
8 жыл бұрын
hello.....i am in the middle of a miniproject on pic18f4580 which is door system using password,,,,,,,,i really need some help in my miniproj......do u have a facebook or any email to contact u!!
@StudentCompanion
8 жыл бұрын
what kind of assistance you want? you can write your on our Facebook wall: facebook.com/StudentCompanion
@amirridzuan9708
7 жыл бұрын
Hello.. may i know on how to interfacing matrix keypad and led matrix.. Let say i want to press 1 it will show 1 on LED matrix and so on
@StudentCompanion
7 жыл бұрын
+amir ridzuan it will depend on the led matrix controller you are using.
@amirridzuan9708
7 жыл бұрын
im using 5x7 led matrix
@StudentCompanion
7 жыл бұрын
It's very tricky to use LED matrix to display anything meaningful beside a simple Characters without using a good library. you can make the leds look like any character you want, and even draw pictures. The math behind the scrolling of text and producing a smooth animation between characters is done by a lot of bit shifting and a lot of math. So we can't explain everything in comments, you need to read a full tutorial which we will do in the future. Read this article from mikroelektronica: learn.mikroe.com/led-matrices/
@alikurra859
6 жыл бұрын
hello , what is the point of having [c-'0' ] at row 102 ? and i defined void display_7seg(char c); on the top of my program but it doesnt count as a function below ? it isn't getting thick and i guess because of this the program doesn't count the char c ? i would be pleasured if you can answer me , have great time !
@StudentCompanion
6 жыл бұрын
You mean your code is generating errors? Can you post your code?
@alikurra859
6 жыл бұрын
now its building ,but i have not an output at Proteus , from where could i send you the codes ?
@StudentCompanion
6 жыл бұрын
Post your full project MPLAB and Proteus. Zip them individually and post them in the forum on our website: www.studentcompanion.co.za/forums/
@cemilekarahaner3055
6 жыл бұрын
we always used to copy the configuration bits to a header file, how come this time we are copying them to c source file?
@StudentCompanion
6 жыл бұрын
Hi. It's the same thing but Microchip recommend to write configuration bits in a C file that's why in most our our new tutorials we are using C file. You can check microchip supplied examples they are using C file.
@guilhermebazzotti7016
5 жыл бұрын
Hi, why did you use LATB instead of PORTB in the rows #define's?
@StudentCompanion
5 жыл бұрын
Always use LAT for output like switching ON or OFF an LED and use PORT for input like reading the status of a switch for PIC18F devices and newer PIC16F series. You might have problems with PORT for output, it might work in simulation but not always in hardware. Please watch this video to learm more why: kzitem.info/news/bejne/lGmhzZqYhWWEpWU
@guilhermebazzotti7016
5 жыл бұрын
@@StudentCompanion thank you!
@StudentCompanion
5 жыл бұрын
You are welcome!
@AslamKhan-gb8rn
3 жыл бұрын
Sir can you tell me why Did you use resister
@StudentCompanion
3 жыл бұрын
To avoid pin floating so you can have a clear value if pin is low or high
@dbrezzy4957
7 жыл бұрын
please kindly explain how these below code codes works.... 1. why did you use INTCON2bits_NOT_RBPU=1;?? what happens if put to "0"?? 2. row1port = (row&0x0001)>>0 row2port = (row&0x0002)>>1 row3port = (row&0x0004)>>2 row4port = (row&0x0008)>>3 please kindly explain how this code work internally... i mean the ">>, and &" i understand that they are use to scan the keypad, but did not understand the code operation 3. secondly.... if(col1port) break; key++; what condition does "col1port" equal to in the 'if( )'?? please explain this code in full. 4. lastly.... if (key!=old_key) old_key=key; return keyPadMatrix[key]; please kindly explain for easy understanding and not for cramming ...thanks in advance
@dbrezzy4957
7 жыл бұрын
please... i await your comments
@StudentCompanion
7 жыл бұрын
+Temitayo Abel which comments? Please refer to our website: www.studentcompanion.net Further explanation is provided.
@dbrezzy4957
7 жыл бұрын
i don't know if am correct about this... row1port = (row&0x0001)>>0 row2port = (row&0x0002)>>1 row3port = (row&0x0004)>>2 row4port = (row&0x0008)>>3 simply give zero(0). i mean row1port=0, row2port=0, row3port=0, row4port=0. is this true??
@StudentCompanion
7 жыл бұрын
+Temitayo Abel what are you trying to do?
@StudentCompanion
7 жыл бұрын
Hi. >> is bitwise shift right; moves the bits to the right, discards the far right bit and if unsigned assigns 0 to the left most bit, otherwise sign extends.
@monitorprey5003
4 жыл бұрын
What does the line 'row1port = (row & 0x0001) >>0' do? Why the >>0?
@StudentCompanion
4 жыл бұрын
row1port is a define for LATBbits.LATB0 as defined in the code in the top. row1port represents Row A of the keypad. To scan for a key pressed, we apply logic 1 to the first row then read the columns output. In this case: row1port = (row & 0x0001) >>0 We are applying 1 in binary for RB0 then shift right by 0, which won't make a difference, then the 2nd line we will shift by 1, then 2 and so on. These values are in binary.
@StudentCompanion
4 жыл бұрын
@@95Gred NO. 0x0001 does not represent RB3-RB0, it just masking, Google PORT masking to learn more. Because the value of row will contain the whole PORT value, we are here reading one bit at a time by masking the rest of bits. 0x0001 will make sure we read the values of the least significant bit only and ignore the rest. Because we are in a for loop scanning our keyboard, the next scan will be to use the mask 0x0002 which will ignore all pins except the second pin and so on.
@StudentCompanion
4 жыл бұрын
@@95Gred 0x0002 is 0010 in binary meaning we are masking all pins except the second pin to read it. 0x0004 is 0100 in binary meaning we are masking all pins except the third pin to read it and so on. Basically if the corresponding bit is 1 then we can read, if it's 0 we ignore it.
@monitorprey5003
4 жыл бұрын
StudentCompanion so by shifting the bits by 1, we are only interested in checking bit 0 or in other words making row2port =1?
@StudentCompanion
4 жыл бұрын
You still can't understand! Google bitwise operators to learn more.
@wariskn7096
7 жыл бұрын
In this video you explain less about the kbd functions....it is hard to get the commands you have provided, because u didn't mention about the command specifications (row and column scanning).......starting was OK but at the middle of programing u have fast forwarded...
@StudentCompanion
7 жыл бұрын
Hi. We hoped everything was self explained as we used comments in the keyboard function. Unfortunately due to time constraint we can't explain everything in one video as it will make the video too long. Many people on KZitem don't prefer to watch videos which are too long. We try to limit the length of our videos whenever it's possible between 8 and 17 min.
Пікірлер: 83