Hi, I have been working on a project which requires interfacing a keypad and a LCD to 8051 microcontroller using keil software(microvision version 5). I have difficulty resolving a C202 error, error statement being ‘PIN_Dx’: undefined identifier. (x being 0,1,2,3,4,5,6,7) I have attached the source code below. Please help
#include <reg51.h> #include <string.h> #define lcd_4bit P1 #define keypad P2 char u1[]="0001",U2[]="0002",U3[]="0003",p[10],k,v1[10]; void lcd_init(); void lcd_cmd(unsigned char b); void lcd_str(unsigned char a); void gotoxy(int x,int y); void lcd_clear(); void lcd_array(char *a); int i=0,d1,d2,d3,z1=1,z2=1,z3=1; int key(); int key() { while(1) { output_low(PIN_D4); output_high(PIN_D5); output_high(PIN_D6); output_high(PIN_D7); if(input(PIN_D0)==0) { while(input(PIN_D0)==0); return('7'); goto k; } else if(input(PIN_D1)==0) { while(input(PIN_D1)==0); return('4'); goto k; } else if(input(PIN_D2)==0) { while(input(PIN_D2)==0); return('1'); goto k; } else if(input(PIN_D3)==0) { while(input(PIN_D3)==0); return('c'); goto k; } output_high(PIN_D4); output_low(PIN_D5); output_high(PIN_D6); output_high(PIN_D7); if(input(PIN_D0)==0) { while(input(PIN_D0)==0); return('8'); goto k; } else if(input(PIN_D1)==0) { while(input(PIN_D1)==0); return('5'); goto k; } else if(input(PIN_D2)==0) { while(input(PIN_D2)==0); return('2'); goto k; } else if(input(PIN_D3)==0) { while(input(PIN_D3)==0); return('0'); goto k; } output_high(PIN_D4); output_high(PIN_D5); output_low(PIN_D6); output_high(PIN_D7); if(input(PIN_D0)==0) { while(input(PIN_D0)==0); return('9'); goto k; } else if(input(PIN_D1)==0) { while(input(PIN_D1)==0); return('6'); goto k; } else if(input(PIN_D2)==0) { while(input(PIN_D2)==0); return('3'); goto k; } else if(input(PIN_D3)==0) { while(input(PIN_D3)==0); return('='); goto k; } output_high(PIN_D4); output_high(PIN_D5); output_high(PIN_D6); output_low(PIN_D7); if(input(PIN_D0)==0) { while(input(PIN_D0)==0); return('/'); goto k; } else if(input(PIN_D1)==0) { while(input(PIN_D1)==0); return('*'); goto k; } else if(input(PIN_D2)==0) { while(input(PIN_D2)==0); return('-'); goto k; } else if(input(PIN_D3)==0) { while(input(PIN_D3)==0); return('+'); goto k; } } k: delay_ms(1); } void lcd_init(); void lcd_cmd(unsigned char b); void lcd_str(unsigned char a); void gotoxy(int x,int y); void lcd_clear(); void lcd_array(char *a); void lcd_init() { lcd_cmd(0x02); lcd_cmd(0x28); lcd_cmd(0x0c); lcd_cmd(0x06); lcd_cmd(0x80); } void lcd_cmd(unsigned char b) { int b1; b1 = (b & 0xF0); output_b(b1); output_high(PIN_B2); delay_ms(1); output_low(PIN_B2); b1 = ((b<<4) & 0xF0); output_b(b1); output_high(PIN_B2); delay_ms(1); output_low(PIN_B2); } void lcd_str(unsigned char a) { int a1; a1=(a&0xF0); output_b(a1 | 0x01); output_high(PIN_B2); delay_ms(1); output_low(PIN_B2); a1=((a<<4)&0xF0); output_b(a1 | 0x01); output_high(PIN_B2); delay_ms(1); output_low(PIN_B2); } void gotoxy(int x,int y) { if(y==0) { lcd_cmd(0x80+x); } else if(y==1) { lcd_cmd(0xc0+x); } } void lcd_clear() { lcd_cmd(0x01); lcd_cmd(0x80); } void lcd_array(char *a) { while(*a) { lcd_str(*a++); } } char u1[]="1234",U2[]="9876",p[10],k,v1[10]; int i=0,d1,d2,z1=1,z2=1; void main() { char m[30]; lcd_init(); lcd_str("Password Based"); gotoxy(0,1); lcd_str("Circuit Breaker"); delay_ms(1500); l1: lcd_clear(); lcd_str("Enter Password:"); gotoxy(0,1); while(1) { k=key(); if(k=='c') { lcd_clear(); gotoxy(0,0); lcd_str("Enter Password:"); gotoxy(0,1); i=0; } else if(k=='=') { p[i]='\0'; goto l; } else { lcd_str(k); p[i]=k; i++; } } l: gotoxy(0,1); d1=strcmp(u1,p); d2=strcmp(u2,p); if(d1==0) { gotoxy(0,0); lcd_str("Correct Password"); gotoxy(0,1); if(z1==1) { output_bit(PIN_C0,1); lcd_str("Load 1 Active"); delay_ms(300); z1==0; goto l1; } else if(z1==0) { output_bit(PIN_C0,0); lcd_str("Load 1 Inactive"); delay_ms(300); z1==1; goto l1; } } else if(d2==0) { gotoxy(0,0); lcd_str("Correct Password"); gotoxy(0,1); if(z2==1) { output_bit(PIN_C1,1); lcd_str("Load 2 Active"); delay_ms(300); z2==0; goto l1; } else if(z2==0) { output_bit(PIN_C1,0); lcd_str("Load 2 Inactive"); delay_ms(300); z2==1; goto l1; } } else { lcd_clear(); lcd_str("Wrong Password"); delay_ms(300); goto l1; } }