Microcontroller › 8051 › plz tell the problem in this lcd program.it is not showing the output
- This topic has 7 replies, 7 voices, and was last updated 11 years, 3 months ago by ddrk.
-
AuthorPosts
-
June 19, 2013 at 2:51 pm #2492gopalParticipant#include<reg51rd2.h>#define command P1#define data P2#define rs P1_0#define rw P1_1#define e P1_2void delay_ms(unsigned int m){int i,j;for(i=0;i<m;i++);for(j=0;j<233;j++);}void lcd_command(unsigned char value){P1=value;rs=0;rw=0;e=1;delay_ms(100);e=0;}void lcd_data(unsigned char value){P2=value;rs=1;rw=0;e=1;delay_ms(100);e=0;}void init(){lcd_command(0x38);lcd_command(0x0e);lcd_command(0x06);}void main(){init();lcd_command(0x80);lcd_data(‘s’);delay_ms(10);lcd_data(‘i’);delay_ms(10);lcd_data(‘r’);delay_ms(10);}June 19, 2013 at 3:47 pm #9990GANESHAPERUMALParticipantplease use this code and reply to this mailid the code is correct or wrong and one more thing pl send correct microcontroller no .ex p89v51rd2 like that .if u have any question pl contact me+919940840471 after 6 pm#include<reg51.h>#define command P1#define data P2sbit rs = P1^0;sbit rw = P1^1;sbit e = P1^2;void delay_ms(unsigned int m){int i,j;for(i=0;i<m;i++);for(j=0;j<233;j++);}void lcd_command(unsigned char value){P1=value;rs=0;rw=0;e=1;delay_ms(100);e=0;}void lcd_data(unsigned char value){P2=value;rs=1;rw=0;e=1;delay_ms(100);e=0;}void init(){lcd_command(0x38);lcd_command(0x0e);lcd_command(0x06);}void main(){init();lcd_command(0x80);lcd_data(‘s’);delay_ms(10);lcd_data(‘i’);delay_ms(10);lcd_data(‘r’);delay_ms(10);}June 19, 2013 at 4:59 pm #9992gopalParticipant
microcontroller no’s at89c051
June 20, 2013 at 2:44 am #9994ANJUSHAParticipantyou have taken port1 for passing commands
and port2 for data but for lcd we consider 8/4 data pins …then how can you make use same 8 pins for port1 and for port2..so consider any one port.
so take port2/port1.use command 0x01 to clear the display before 0x80 and b/w every command in intializing lcd use delay;
June 20, 2013 at 8:03 am #9998manoharParticipant//use this code and connect the pins correctly data port is P1 here control pins P2.0 P2.1,P.2#include<reg51.h>#define rs P2^0 ///edited#define rw P2^1 //edited#define e P2^2 //editedvoid delay_ms(unsigned int m){int i,j;for(i=0;i<m;i++);for(j=0;j<233;j++);}void lcd_command(unsigned char value){P1=value;rs=0;rw=0;e=1;delay_ms(100);e=0;}void lcd_data(unsigned char value){P1=value;///editedrs=1;rw=0;e=1;delay_ms(100);e=0;}void init(){lcd_command(0x38);lcd_command(0x0e);lcd_command(0x06);}void main(){init();lcd_command(0x80);lcd_data(‘s’);delay_ms(10);lcd_data(‘i’);delay_ms(10);lcd_data(‘r’);delay_ms(10);}June 20, 2013 at 2:48 pm #9999PraneethParticipant#include<reg51.h>#define rs P1_0#define rw P1_1#define e P1_2void delay_ms(unsigned int m){int i,j;for(i=0;i<m;i++);for(j=0;j<233;j++);}void lcd_command(unsigned char value){P1=value;rs=0;rw=0;e=1;delay_ms(100);e=0;}void lcd_data(unsigned char value){P2=value;rs=1;rw=0;e=1;delay_ms(100);e=0;}void init(){lcd_command(0x38);lcd_command(0x0e);lcd_command(0x06);lcd_command(0x01);}void main(){init();lcd_command(0x80);lcd_data(‘s’);delay_ms(10);lcd_data(‘i’);delay_ms(10);lcd_data(‘r’);delay_ms(10);}June 28, 2013 at 4:17 am #10047AJISH ALFREDParticipantHi all,
The issues with the LCD are already discussed so many times in this forum. You can search the previous discussions regarding the LCD in this forum and I’m sure that it will help you.
Normally the problems occurs due to:
-wrong hardware connections
-loose contact of any data or control lines
-short circuit of the data or control lines
-port not made as output
-wrong or incomplete initializing commands
-wrong method of activating the enable pin
-insufficient delay
Check all of them.
June 28, 2013 at 4:51 am #10050ddrkParticipantjust change the this
connect your lcd data pins to P2
void lcd_command(unsigned char value){P2=value;rs=0;rw=0;e=1;delay_ms(100);e=0;}void lcd_data(unsigned char value){P2=value;rs=1;rw=0;e=1;delay_ms(100);e=0;}orif you use this connect ur lcd data pins to P1void lcd_command(unsigned char value){P1=value;rs=0;rw=0;e=1;delay_ms(100);e=0;}void lcd_data(unsigned char value){P1=value;rs=1;rw=0;e=1;delay_ms(100);e=0;} -
AuthorPosts
- You must be logged in to reply to this topic.