Showing posts with label interfacing. Show all posts
Showing posts with label interfacing. Show all posts

Saturday, January 24, 2015

Usb Communication With PIC Microcontroller [step by step tutorial]



usb connection with pic microcontroller
mikroc usb tutorial

USB communication is better than serial communication. Hardware interfacing is very easier than Rs 232 . In USB 1.0 communication  Low Speed is-1.5Mbit/second  & High Speed is -12Mbit/second . The upgrade version provides more speed than older version. USB-3.0  has higher speed, 5Gbit/second and it's called super speed. For more information you can visit this page >>  Wikipedia Usb.

In this tutorial I will use pic18f2550 microcontroller & it is very popular for usb. Now you can ask a question, how do we get our MCU to work with high speed or low seed ?
At 6MHz clock we will get low speed and at 48MHz Clock we will get High speed. In this tutorial we will try to make higher speed connection. We are not going to use 48MHz clock, because it is very noisy. We will try another technique instead of it. Microchip company provides internal PLL( Phase Locked Loop ) circuit  in some of specific  products and  pic18f2550 has internal PLL Circuit. Now look at the picture :

Phase Locked Loop Cuit
PLL Circuit
The PLL circuit  converts 4MHz clock to 48MHz clock. So, we need 4MHz clock. We have to divide the clock in such way so that we can get  result 4MHz. Look at here, If we use 20MHz divide it by 5 and we get 4. Example : (20/5)=4 ,(12/3)=4. We have to define this in the  source code.

Now let's create a project in Proteus 8.

Proteus 8 Circuit :

Step 1:
How to Create Project in Proteus 8
How to Create Project in Proteus _1
Step 2:
How to Create Project in Proteus 8
How to Create Project in Proteus 8_2

Step3 :
How to Create Project in Proteus 8_3
How to Create Project in Proteus 8_3

 Step 4:
Usb Communication With PIC Microcontroller [step by step tutorial]


Step 5:
How to find parts in Proteus 8
How to find parts in Proteus 8
 Step 6:
How to find parts in Proteus 8_3
How to find parts in Proteus 8
Step 7:

usb interfacing with pic microcontroller Circuit
Usb  Interfacing With PIC Microcontroller Circuit

Now let's create a project in MikroC.

MikroC Code :

Step 1:
Create New Project in MikroC_1
Create New Project in MikroC_1
Step 2:
Create New Project in MikroC_2
Create New Project in MikroC_2
Step 3:
Create New Project in MikroC_3
Create New Project in MikroC_3
Step 4:
 Include All Library in mikroc
Include All Library
Step 5:
Editing MikroC project
Editing MikroC project settings_1
Step 6:
USB Communication With PIC Microcontroller
USB Communication With PIC Microcontroller


1. As we know PLL circuit takes input 4MHz clock. So we have to divide 12MHz by 3 so that we can get 4MHz clock. If we use 4MHz we have no need  this part .
2 & 3 . We are using USB 1.0 and it's High Speed clock 48MHz. So we have to devide it by 2.

4 . Here we are using 12MHz Crystal clock and the oscillator selection should be HS Oscillator.          

5 . We have to enable voltage regulator. Basically it is an internal  3.3 voltage regulator of pic18f2550. If we enable this, it is required to connect vusb pin with a 220 nf capacitor.

#Source Code :

 

unsigned char receivedata[64] absolute 0x500;  //  <--Variable Declaration  
 unsigned char senddata[64] absolute 0x580;  
 int i=0;  
 void Interrupt(){  
 USB_Interrupt_Proc();    //<--Interrupt function  
 }  
 void main()   //<--The Main Function  
 {  
 HID_Enable(&receivedata,&senddata);  //<--To Enable HID  
 while(1){             //<-- Infinity LOOP  
 while(!HID_Read());   //<--for reading  
 for(i=0;i<64;i++){  
 senddata[i]=receivedata[i];   //<--Sending received data to senddata[i] variable  
 }  
 while(!HID_Write(&senddata,64)); //<--for writting  
 }  
 }  
 

1. unsigned char receivedata[64] absolute 0x500;

    unsigned char senddata[64] absolute 0x580;


Here we have created character type two array variable senddata & receivedata. During USB Communication we must have to keep all data in USB RAM. PIC 18F2550 microcontroller's USB RAM memory address begins with 0x500 and ends with 0x7F. That's why, we kept the receivedata[64]  in 0x500 location and senddata[64] in 0x580.
2. 

void Interrupt(){


USB_Interrupt_Proc();}


void Interrupt() is one user defined function which contains USB_Interrupt_Proc()  function inside . Interrupt means restriction for something. When  interrupt is enabled, microcontrller doesn't perform main function. It will perform only interrupt function or ISR(interrupt service routine). After clearing the flag main method works.

3. HID_Enable(&receivedata,&senddata); 

This function will initialize USB. It locates receivedata variable and  send data variable.

Note : HID means "Human Interface Device"

4. char HID_Read();

This function receives data. If receiving is failed, it returns 0. Otherwise it returns character .

while(!HID_Read());

It means, this function tries to receive data until  data are being received .

char HID_Write();


This function receive data. If receiving is failed, it returns 0. Otherwise it returns the numbers of data .while(!HID_Write());


 It means, this function tries to send data until  data are being sent. 

5.for(i=0;i<64;i++>

senddata[i]=receivedata[i];    

}

This loop will run from 0 to 63 and will keeps the received data to senddata variable from receivedata variable.  

  #Descriptor File Addition

Descriptor File : This file will make your pc understand about device's informations. Like
Manufacture Name, Product ID, Vendor ID  etc.
Now i will show you. How to create a Descriptor file .



Step 7:
Create Descriptor FIle_1
Create Descriptor File_1
Step 8:
Create Descriptor FIle_2
Create Descriptor FIle_2
Step 9:
Adding descriptor file with MikroC Project .
Adding Descriptor File
Adding Descriptor File
Step 10:
Step 11:

Usb Communication With PIC Microcontroller [step by step tutorial]
Step 12:
usb interfacing with pic microcontroller
How to upload hex file in proteus_1
Step 13:
How to upload hex file in proteus
How to upload hex file in proteus_2
Step 14:
How to upload hex file in proteus
How to upload hex file in proteus_3
Step 15:
In proteus Simulation we need to install virtual usb .
How to install Virtual USB in proteus
Install Virtual USB in proteus
Step 16:
Run Proteus Project
Run Project

Now go to the Proteus Circuit and Just Run the project .

Output:

Now go to the Tool >>HID Terminal >> click on Terminal .
HID Terminal of MikroC
HID Terminal of MikroC
HID Terminal of MikroC
HID Terminal Output




                                          Thank You!                                                           

Thursday, January 01, 2015

Digital Clock [Real Time] Using DS1307 and PIC Microcontroller in Proteus



This tutorial contains description of microcontroller based digital clock and DS1307. We know microcontroller is a computer and specific time required to complete each task. So we cannot get real time and that's why we need a real-time clock IC. We will use DS1307 IC in this tutorial.
 Digital Clock [Real Time] Using DS1307 and PIC Microcontroller [step by step ]
 Digital Clock [Real Time] Using DS1307 and PIC Microcontroller [step by step ]

DS1307 IC:

DS1307 is a real-time clock IC which basically works with low power and returns BCD(Binary Coded Decimal)  number. We will describe later about BCD.
Through this IC we can get year, month, date, hour, minute and second. The months, days, second can be incremented automatically and It can operate either in 24-hour format or 12-hour format with AM/ PM.DS1307 has built-in power sensing circuit which can backup the IC automatically during the failure of power supply.Crystal (1000KHz)  is required to operate this IC and don't need any external capacitor connection. 
DS1307
At this stage, we have got basic information about DS1307. In this tutorial, we need to use I2C communication with Microcontroller. Description of I2C communication is given below.

I2C Communication with Microcontroller using MikroC 

The I2C(I Squared C) communication means "  Inter-Integrated Circuit " communication. A microcontroller can communicate with low power peripherals through I2C.To make a successful I2C communication we just need two ends or pins[ SCL and SDA ].Here SCL for clock selection and SDA for data. Both SCL and SDA are Open Drain drives that means the chip can drive it's low output and cannot drive the high output. It 's required to connect two pull up resistors in such way that one end of both resistors with +5v and others end with SCL, SDA respectively so that the higher output can be driven. The pull-up resistors value will be according to the I2C bus frequency.We are using 2k Ohm pull up resistor in this Tutorial.


MikroC Library for I2C :

  • void I2C1_Init(const unsigned long clock); this function is needed to initialize and returns nothing .We have to provide frequency as it's arguments .    Example  : I2C1_Init(100000);
  • unsigned short I2C1_Start(void) ; this function is needed to start communication .                  Example I2C1_Start();
  • void I2C1_Repeated_Start(void); for starting again .
  • unsigned short I2C1_Is_Idle(void);  
Returns 1 if I²C bus is free, otherwise returns 0.

  •  unsigned short I2C1_Rd(unsigned short ack); Returns one byte from the slave.
  • unsigned short I2C1_Wr(unsigned short data_); Sends data byte (parameter data) via I²C bus.

  • void I2C1_Stop(void); To stop the signal .


     

    The Time Keeper Register  of DS1307:


The Time Keeper Register  of DS1307:

The Time Keeper Register  of DS1307


Here we can see the address of each function ,data bits and data range .First we have to initialize the I2C using 10kHz frequency and start the communication using start function .Now if we like to write , it's required to send out 0xD0 [D0=0x68+0]through write function so that the IC can be enabled for writing to us.Instructions given below :
I2C1_Wr(0xD0); [D0=0x68+0]
   I2C1_Wr(address);
During reading the data comes from DS1307 , we need to send out 0xD1 [D1=0x68+1]through write functiono that the IC can be enabled for reading to us .Instructions given in below :
 I2C1_Wr(0xD1);[D1=0x68+1]
data = I2C1_Rd(0);
Here in I2C1_Rd(0); To read data we will use Readdata(adrs) function 
and it is a user defined function. In "Readdata(0);" function we will write 0 as
argument and the 0 means address of Seconds Register.This function returns 
short type data in BCD . I this way we can read data from each address .An
 important thing needed to notice that bit 6 of hour register is defined as the 
24-hour or 12-hour mode selection bit.If we select 1 the bit 5 of hour used for
 representing AM/PM and if we select 0 the bit 5 used for representing hour .

BCD Number:

BCD number means Binary Coded Decimal number where each binary number is in 4bit .If we consider a decimal number 21 ,the BCD conversion will be 00100001 .Here blue represents the 2 and red represents 1. In that way we get BCD .Now the question is how can we get character from BCD  ?Cause if we like to show in LCD , we need character .Look at the code given below :


First Char from BCD

char firstcharofbcd(char bcddata)
{
char tireturn;

      tireturn= (bcddata >> 4) +0x30; Here we are shifting 4 bits to right hand side .

  return tireturn;
}
If we consider 21 we can get 2 in character format .Because in short format data we added 0x30 , which is  character '0' .So the sum of '0'+0010 = '2' .

Second Char from BCD


char secondcharofbcd(char bcddata)
{
char toret;
toret=(bcddata & 0x0F) + 0x30;

  return toret;
} .
   0x0F means '00001111' .We know in an AND gate if any input is low or 0 and the gate output is 0.If all input is 1 and we can get output 1.So by applying AND operation between 0x0F and BCD , we can make first  0000 bit as 0 .Look at the example given below :

00100001
00001111 &
-------------
00000001= 1

I think we get all required basic information .Now lets create a project in Proteus .


Proteus Project : 

Please follow the instructions given below :




Pick all the required parts and Complete the circuit as given below :



Note : In practical , you have to connect 12MHz crystal between pin9 and pin10 . Also remember that 1 & 20 will be connected with VDD and 8 & 19 will be connected with GND

 Digital Clock [Real Time] Using DS1307 and PIC Microcontroller [step by step ]
 Digital Clock [Real Time] Using DS1307 and PIC Microcontroller [step by step ]
 

Now we need the .hex file .So lets Create a project in MikroC .Please follow the steps given below :

MikroC Code :




///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

Load the source code on microcontroller and just run the project now . 

Source Code :

 
  

sbit LCD_RS at RB7_bit;
sbit LCD_EN at RB6_bit;
sbit LCD_D5 at RB4_bit;
sbit LCD_D4 at RB5_bit;
sbit LCD_D6 at RB3_bit;
sbit LCD_RS_Direction at TRISB7_bit;
sbit LCD_D7 at RB2_bit;
sbit LCD_EN_Direction at TRISB6_bit;
sbit LCD_D5_Direction at TRISB4_bit;
sbit LCD_D4_Direction at TRISB5_bit;
sbit LCD_D6_Direction at TRISB3_bit;
I2C1_Wr(0xD0);
sbit LCD_D7_Direction at TRISB2_bit;
short readdata(short adrs){
}
short getinp;
I2C1_Start();
I2C1_Wr(adrs);
I2C1_Repeated_Start();
I2C1_Wr(0xD1);
I2C1_Stop();
getinp=I2C1_Rd(0);
return getinp;
I2C1_Wr(writedat);
void writedata(unsigned short adrs,short writedat)
{
I2C1_Start();
I2C1_Wr(0xD0);
char firstcharofbcd(char bcddata)
I2C1_Wr(adrs);
I2C1_Stop();
return toret;
} {
char tireturn;
tireturn= (bcddata >> 4) +0x30;
return tireturn;
}
{
char secondcharofbcd(char bcddata)
char toret;
short wk;
toret=(bcddata & 0x0F) + 0x30;
}
char time[] = " : : ";
char date[] = " / / ";
short inc,in;
short chk;
short hr;
short sec;
short mint;
short h, ht;
char wkd;
short day;
short mon;
TRISA = 0x3F;
short yr;
void main() {
I2C1_Init(100000); //DS1307 I2C is running at 100KHz
inc=0;
CMCON = 0x07; // To turn off comparators
ADCON1 = 0x0F; // To turn off analog to digital converters
mint = readdata(1);
Lcd_Init(); // Initialize LCD
Lcd_Cmd(_LCD_CLEAR); // Clear display
Lcd_Cmd(_LCD_CURSOR_OFF); // Cursor off
sec = readdata(0);
Lcd_out(1,1,"Time:");
while(1){
Finally i make it manually , you can see here .Thank You !!
hr = readdata(2);
h=hr; // for 12 hour format
// here means 00100000 in binary and we can get a signal in change of AM/PM
/* I dont know why 12hour format is not working .I worked hard but it didnot work .
*/
///////////////////////////////////////
chk=1; }
h= Bcd2Dec(h);
if(h-12>=0){
ht=12 ;
if(h-12==0) {
chk=1; }
chk=1; }
if(h-12==1) {
ht=1 ;
ht=3 ;
if(h-12==2) { ht=2 ;
chk=1; }
if(h-12==3) {
chk=1; }
chk=1; } if(h-12==4) {
if(h-12==5) {
ht=4 ;
ht=5 ;
if(h-12==6) {
chk=1; }
ht=6;
if(h-12==7) {
chk=1; }
ht=7;
chk=1; }
chk=1; } if(h-12==8) {
if(h-12==9) {
ht=8;
day = readdata(4);
ht=9 ;
chk=1; }
if(h-12==10) {
ht=10;
if(h-12==11) {
ht=11 ;
} else{
chk=1; }
chk=0;
if(h==0){
ht=12;
chk=0;
}
else{
ht=h;
///////////////////////////////////////////////////////////////////
}
}
h=Dec2Bcd(ht);
date[0] = firstcharofbcd(day);
wk=readdata(3);
mon = readdata(5);
time[0] = firstcharofbcd(h);
yr = readdata(6);
time[3] = firstcharofbcd(mint);
time[1] =secondcharofbcd(h);
time[6] = firstcharofbcd(sec);
time[4] = secondcharofbcd(mint);
date[11] ='n';
time[7] = secondcharofbcd(sec);
date[1] = secondcharofbcd(day);
date[4] = secondcharofbcd(mon);
date[3] = firstcharofbcd(mon);
date[6] = firstcharofbcd(yr);
switch(wkd){
date[7] = secondcharofbcd(yr);
wkd=secondcharofbcd(wk);
date[10] ='u';
case '1': date[9] ='S';
date[10] ='u';
date[12] ='d';
date[14] ='y';
date[13] ='a';
break;
date[10] ='o';
case '2':
date[9] ='M';
date[13] ='a';
date[11] ='n';
date[12] ='d';
date[9] ='T';
date[14] ='y';
break;
date[11] ='u';
case '3': date[11] ='e';
date[12] ='d';
date[14] ='y';
date[13] ='a';
break;
date[10] ='e';
case '4':
date[9] ='W';
date[13] ='a';
date[11] ='d';
date[12] ='d';
date[9] ='T';
date[14] ='y';
break;
date[12] ='d';
case '5': date[10] ='h';
date[12] ='d';
date[13] ='a';
date[14] ='y';
break;
date[9] ='F';
case '6':
date[11] ='i';
date[10] ='r';
date[13] ='a';
date[12] ='d';
date[14] ='y';
date[9] ='S';
break;
case '7':
date[10] ='a';
if(mint>59){
date[11] ='t';
date[13] ='a';
date[14] ='y';
break;
}
time[9] = 'P';
if(chk)
{
else
time[10] = 'M';
} {
time[10] = 'M';
time[9] = 'A';
}
Lcd_out(1, 6, time);
inc++;
Lcd_out(2, 1, date);
if(PORTA.F0==0){
wk= readdata(3);
delay_ms(300); mint=Bcd2Dec(mint);
mint=0;
mint=mint+inc; }
mint=Dec2Bcd(mint);
writedata(1,mint);
if(PORTA.F1==0){
}
h=readdata(2);
delay_ms(300);
inc++;
inc=Bcd2Dec(h);
if(inc>23){
writedata(2,h);
inc=0;
}
h=Dec2Bcd(inc);
}
//////
inc=0;
if(PORTA.F2==0){
} else if(mon==1 | mon==3 | mon==5 | mon==7 | mon==8 | mon==10| mon==12){
delay_ms(300); in=Bcd2Dec(wk);
if(in>7){
in++;
in=1;
wk= Dec2Bcd(in);
}
///////
writedata(3,wk);
inc=Bcd2Dec(h);
h=readdata(4);
inc++;
if(yr%4==0){
yr=readdata(6);
yr=Bcd2Dec(yr);
if(mon==2){
mon=readdata(5);
mon=Bcd2Dec(mon);
if(inc>31){
if(inc>29){
inc=1;
inc=1;
}
inc=1;
}
if(inc>30){
}else{
inc=1;
}
mon=readdata(5);
}
}else{
if(mon==2) {
mon=Bcd2Dec(mon);
if(inc>28){
else if(mon==1 | mon==3 | mon==5 | mon==7 | mon==8 | mon==10| mon==12){
inc=1;
}
if(inc>31){
}
if(PORTA.F4==0){
}
}else{
if(inc>30){
inc=1;
}
day=Dec2Bcd(inc);
}
}
if(PORTA.F3==0){
writedata(4,day);
} inc=0;
}
inc++;
delay_ms(300);
inc=0;
if(inc>12){
}
mon=Bcd2Dec(mon);
mon=mon+inc;
mon=1;
if(mon>12){
inc++;
mon=Dec2Bcd(mon);
writedata(5,mon);
}
} inc=0;
delay_ms(300);
if(inc>59){
yr=Bcd2Dec(yr);
inc=0;
}
if(yr>59){
yr=yr+inc;
yr=1;
writedata(6,yr);
}
yr=Dec2Bcd(yr);
if(PORTA.F5==0){
}
wk= readdata(3);
delay_ms(300);
//////
in=Bcd2Dec(wk);
wk= Dec2Bcd(in);
in++;
if(in>7){
in=1;
} writedata(3,wk);
}
/////// }

Compile Source Code

Load hex file to the microcontroller .

 

 

 

 

 

Download This Project[google_drive]

Thank You!






Sunday, December 07, 2014

Matrix [4x4] Keypad interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]




 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]


Basically a matrix keypad[ 4x4] can be compared as a keyboard of microcontroller .The keypad contains 16 buttons .Internal architecture of keypad described below :
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]
Taken from Internet

You can see  the button's structure  .Here each row is connected with ground through 10k ohm resistor . Now consider that A=1, B=0,C=0,D=0 and column A get +5v .At this situation , if you press   button[A,E]  , the E link get +5v .In this way for button[A,F] , F=+5v or 1, button[A,G] , G=1, button[A,H] , H= 1.
Listen , if we can make ABCD(1000) ,ABCD(0100),ABCD(0010), ABCD(0001) through a loop . Now any button  pressed  , we can uniquely identify the button .In this way the matrix keypad works .

Now Create a project in Proteus :

Proteus Project :

Please follow the steps




I am just trying to make easy for beginner .Now follow the instruction for pick parts from library .




Now pick  PIC18F4550  microcontroller , 22pf capacitor ,crystal , LCD DISPLAY [LM016L] , keypad  from proteus library .Now see the complete circuit given below :
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]
 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]

Here i have connected each column with +5v instead of GND and now i am going to provide (1000) ,(0100),(0010),(0001) in each row respectively .So if any button  is pressed we get 0 according to this.
Now We have completed the Circuit and create a project in MikroC .

MikroC Project :

If  you are a beginner , please follow the steps given below :

Source Code :

  


  sbit LCD_RS at RB7_bit;  
  sbit LCD_EN at RB6_bit;  
  sbit LCD_D4 at RB5_bit;  
  sbit LCD_D5 at RB4_bit;  
  sbit LCD_D6 at RB3_bit;  
  sbit LCD_D7 at RB2_bit;  
  sbit LCD_RS_Direction at TRISB7_bit;  
  sbit LCD_EN_Direction at TRISB6_bit;  
  sbit LCD_D4_Direction at TRISB5_bit;  
  sbit LCD_D5_Direction at TRISB4_bit;  
  sbit LCD_D6_Direction at TRISB3_bit;  
  sbit LCD_D7_Direction at TRISB2_bit;  
  // End LCD module connections  
  char ch[]="   ";  
  int j=0,ak=0,i=0;  
  void main() {  
  ADCON1=0x0F;  
  CMCON=7;  
  TRISA.F0=1;  
  TRISA.F1=1;  
  TRISA.F2=1;  
  TRISA.F3=1;  
  TRISC.F0=0;  
  TRISC.F1=0;  
  TRISC.F2=0;  
   TRISC.F4=0;  
  Lcd_Init();  
   Lcd_Cmd(_LCD_CLEAR);    // Clear display  
  Lcd_Cmd(_LCD_CURSOR_OFF);  
  delay_ms(200);  
  j=0;  
   while(1){  
    PORTC=0x00;  
    LCD_Out(1,1,"Matrix Keypad");  
    ak=5;  
    delay_ms(200);  
   while (ak==5){  
  PORTC=0x01;       //  
  if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   ak=2;  
   Lcd_Chr(2,4,'7');  
    ch[j]='7';  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'4');  
   ak=2;  
    ch[j]='4';  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
  Lcd_Chr(2,4,'1');  
      ch[j]='1';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
     Lcd_Chr(2,4,'C');  
    ch[j]='C';  
   ak=2;  
   j++;  
  }  
   PORTC=0x02;  
   if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'8');  
  ch[j]='8';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'5');  
  ch[j]='5';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'2');  
  ch[j]='2';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
    Lcd_Chr(2,4,'0');  
   ch[j]='0';  
   ak=2;  
   j++;  
  }  
  /////////////////////////  
  PORTC=0x04;        //  
   if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'9');  
  ch[j]='9';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'6');  
   ch[j]='6';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'3');  
    ch[j]='3';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
    Lcd_Chr(2,4,'=');  
    ch[j]='=';  
   ak=2;  
   j++;  
  }  
   /////////////////////////  
  PORTC=0x10;        //  
   if(PORTA.F0==1 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==0) {  
   Lcd_Chr(2,4,'/');  
  ch[j]='/';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==1 & PORTA.F2==0 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'*');  
   ch[j]='*';  
   ak=2;  
   j++;  
  }  
  if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==1 & PORTA.F3==0) {  
    Lcd_Chr(2,4,'-');  
    ch[j]='-';  
   ak=2;  
   j++;  
  }  
   if(PORTA.F0==0 & PORTA.F1==0 & PORTA.F2==0 & PORTA.F3==1) {  
    Lcd_Chr(2,4,'+');  
    ch[j]='+';  
   ak=2;  
   j++;  
  }  
  }  
   }  
  }  




 Now follow the instructions, how to create .hex file and save .


 Now go to Proteus and Run the Project .



 Matrix [4x4] Keypad  interfacing with PIC Microcontroller [ PIC18f2550 ] in Proteus [Step by Step]

 In this way you will able to interface Keypad with Microcontroller .

Result Video :



Download This Project(Google Drive)


Thank You!



Please Share and Bookmark posts.

Tags

: (1) 18F2550 (1) 36KHz (3) and (1) arduino (1) Based (1) battery (1) Bipolar (1) Blinking (1) blinks (1) Bluetooth (1) bluetooth device interfacing (1) bluetooth module (1) button (1) circuit (1) clock (1) control (1) crystal oscillator (3) Db9 (1) DC Motor (2) digital (2) Digital Voting Machine (1) digital voting machine using pic (1) display (2) DS1307 (1) electronic (1) embedded c programming tutorial (11) embedded c tutorial (11) experiment kit (4) external interrupt (4) flash (1) flashing (1) Gas Leakage detector (1) HC-06 (1) home (1) how (1) How to (10) i2c tutorial (1) in (1) indicator (1) infrared Connection (3) interface (8) interfacing (3) Interrupt (3) Introduction (1) IR Connection (3) IR Receiver (4) IR Transmitter (4) key pad (1) keyboard (1) keypad (1) lavel (1) Lcd 16x2 (2) lcd 2x16 (2) led (1) lm35 (2) LPG (1) machine (1) make (1) Make bootloader (1) making (1) matrix (1) max232 (1) membrane keyboard (2) meter (2) Micocontroller (1) microchip (4) microchip pic (2) microchips (3) microcontroller (9) microcontroller based (3) microcontroller programming (3) Microcontroller Project (4) Microcontroller Projects (1) microcontroller_project (2) microcontrollers (4) Microprocessor (2) mikroC (5) mikroc code to start and stopstart and stop dc motor (1) mikroc pro for pic (2) Motion detector (1) MQ-9 Gas Sensor (1) musical (1) NEC Protocol (4) pcb (5) PIC (3) pic controller (11) pic microcontroller (11) pic microcontroller tutorial (11) pic programming (1) pic programming in c (12) pic proteus (1) Pic Tutorial (12) pic18 (2) pic18f2550 (11) picmicrocontroller (4) picRFモジュール (1) PIR Motion Sensor (1) printed circuit board (1) proteus (6) pulse width modulation (1) push (1) push button (1) PWM (1) real (1) rf transmitter (3) Rs 232 (1) Rs232 (1) scroll (1) scrolling (1) Serial communication (1) Serial Connection (1) Serial Port (1) serial port rs232 (1) Servo Motembedded c programming tutorial (1) simulation (2) Soil Moisture Meter (1) speed control (1) step by step (7) step bystep (1) Stepper Motor (2) text (2) Thief Detector (1) time (1) timer (4) timer0 (4) tone (1) TSOP38236 Receiver (4) tutorial (2) Unipolar (1) USART Connection (1) USB (1) usb 1.0 (1) USB bootloadere (1) USB HID (1) using (9) voltmeter (1) voting (1) water level indicator (3) with (2) work (1)

Traffic Feed


Live Traffic Feed
Visitor Tracking

Leave Your Message Here

Name

Email *

Message *

Like on Facebook