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.

Alpha-numeric Numbers Display

Status
Not open for further replies.

vead

Full Member level 5
Joined
Nov 27, 2011
Messages
285
Helped
3
Reputation
6
Reaction score
3
Trophy points
1,298
Location
india
Activity points
3,815
Hello
I want to display Alpha-numeric Numbers on screen but I am not getting number on screen
8051- keil - LCD 16*2
Please look at design and program. whats reason why Its not working?

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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
#include<reg51.h>
 
#define  Data_Port_Pins  (P0)
 
sbit  Register_Select_Pin  = P2^0;           
sbit  Read_Write_Pin  = P2^1;                
sbit  Enable_Pin  = P2^2;                     
 
sbit Column_1 = P1^0;     
sbit Column_2 = P1^1;
sbit Column_3 = P1^2;
sbit column_4 = P1^3;
 
sbit Row_1 = P1^4;
sbit Row_2 = P1^5;
sbit Row_3 = P1^6;
sbit Row_4 = P1^7;
 
void delay(int a)
{
   int i;
   for(i=0;i<a;i++);   
}
  /* send data */
  void LCD_Data (unsigned char Data)
  {
      Data_Port_Pins = Data;
      Register_Select_Pin=1;
      Read_Write_Pin=0;
      Enable_Pin =1;
      delay(150);
      Enable_Pin =0;
          delay(150);
  }
    
 
  /* Send command */
  void LCD_Command (unsigned char command)
  {
        Data_Port_Pins = command;
        Register_Select_Pin =0;
        Read_Write_Pin=0;
        Enable_Pin =1;
        delay (150);
        Enable_Pin =0;
            delay(150);
  }
    
    void LCD_Initialization(void)
{
 
       delay(15000);
       LCD_Command(0x30);
       delay(4500);
       LCD_Command(0x30);
       delay(300);
       LCD_Command(0x30);
       delay(650);
       LCD_Command(0x38);    //function set
       LCD_Command(0x0c);    //display on,cursor off,blink off
       LCD_Command(0x01);    //clear display
       LCD_Command(0x06);    //entry mode, set increment
}
 
 
    void Return(void)     //Return to 0 location on LCD
{
      LCD_Command(0x02);
      delay(1500);
}
 
void Port_Initialization(void)
{
    P0 = 0x00;   //used as data port for LCD
    P1 = 0x00;   //used for generating outputs and taking inputs from Keypad
    
}
 
char READ_SWITCHES(void)    
{    
    Row_1 = 0; Row_2 = 1; Row_3 = 1; Row_4 = 1;     //Test Row 1
 
    if (Column_1 == 0) { delay(10000); while (Column_1==0); return '1'; }
    if (Column_2 == 0) { delay(10000); while (Column_2==0); return '2'; }
    if (Column_3 == 0) { delay(10000); while (Column_3==0); return '3'; }
   
 
    Row_1 = 1; Row_2 = 0; Row_3 = 1; Row_3 = 1;     //Test Row B
 
    if (Column_1 == 0) { delay(10000); while (Column_1==0); return '4'; }
    if (Column_2 == 0) { delay(10000); while (Column_2==0); return '5'; }
    if (Column_3 == 0) { delay(10000); while (Column_3==0); return '6'; }
    
 
    Row_1 = 1; Row_2 = 1; Row_3 = 0; Row_4 = 1;     //Test Row C
 
    if (Column_1 == 0) { delay(10000); while (Column_1==0); return '7'; }
    if (Column_2 == 0) { delay(10000); while (Column_2==0); return '8'; }
    if (Column_3 == 0) { delay(10000); while (Column_3==0); return '9'; }
    
 
    Row_1 = 1; Row_2 = 1; Row_3 = 1; Row_4 = 0;     //Test Row D
 
    if (Column_1 == 0) { delay(10000); while (Column_1==0); return '*'; }
    if (Column_2 == 0) { delay(10000); while (Column_2==0); return '0'; }
    if (Column_3 == 0) { delay(10000); while (Column_3==0); return '#'; }
    
 
    return 'n';               // Means no key has been pressed
}
 
char get_key(void)               //get key from user
{
    char key = 'n';              //assume no key pressed
    while(key=='n')              //wait untill a key is pressed
    key = READ_SWITCHES();       //scan the keys again and again
    return key;                  //when key pressed then return its value
}
 
int main(void)
{
   char key;                // key char for keeping record of pressed key
  
   Port_Initialization();
     LCD_Initialization();               // Initilize LCD
   while(1)
   { 
     key = get_key();       // Get pressed key
     LCD_Command(0x01);        // Clear screen
     LCD_Data(key);        // Echo the key pressed to LCD
   }
}

 

Attachments

  • EDA.jpg
    EDA.jpg
    240.6 KB · Views: 59

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top