- This topic has 5 replies, 4 voices, and was last updated 11 years, 7 months ago by Gopi.g.
-
AuthorPosts
-
March 14, 2013 at 5:47 pm #2189ParthParticipant#include<reg52.h>#include<intrins.h>#include<string.h>#define LCD P0#define DELAY _nop_();void integer_lcd(int);sbit m1=P2^2;sbit op=P2^3;sbit time=P2^0;void init_lcd(void);void cmd_lcd(unsigned char);void data_lcd(unsigned char*);unsigned int i,n;void delay_ms(int);void main(){init_lcd();m1=0;time=1;op=0;n=10;display_lcd(“Foot Step Based”);cmd_lcd(0xC0);display_lcd(“Street Light”);delay_ms(100);cmd_lcd(0x01);while(1){cmd_lcd(0x80);display_lcd(“Foot Step Based”);cmd_lcd(0xC0);display_lcd(“Street Light”);if(m1=1){cmd_lcd(0x01);cmd_lcd(0x80);display_lcd(“Stepped”);cmd_lcd(0xC0);display_lcd(“Light ON “);for(i=0;i<=n;i++){cmd_lcd(0xc0);display_lcd(“Time: 00:”);integer_lcd(i);op=1;delay_ms(250);}i=0;op=0;}if(time==0){cmd_lcd(0x01);cmd_lcd(0x80);display_lcd(“Set Time”);cmd_lcd(0xC0);display_lcd(” “);n=n+1;integer_lcd(n);}}}void init_lcd(void){cmd_lcd(0x28);cmd_lcd(0x28);cmd_lcd(0x28);cmd_lcd(0x0C);cmd_lcd(0x06);cmd_lcd(0x01);}void cmd_lcd(unsigned char var){LCD = ((var& 0xF0) | 0x04);LCD = 0;LCD = ((var<< 4) | 0x04);LCD = 0;delay_ms(2);}void data_lcd(unsigned char var){LCD = ((var& 0xF0) | 0x05);LCD = 0;LCD = ((var<< 4) | 0x05);LCD = 0;delay_ms(2);}void display_lcd(char *str){while(*str)data_lcd(*str++);}void delay_ms(intcnt){int i;while(cnt–)for(i=0;i<500;i++);}void integer_lcd(int n){unsigned char c[6];unsigned int i=0;if(n<0){data_lcd(‘-‘);n=-n;}if(n==0)data_lcd(‘0’);while(n>0){c[i++]=(n%10)+48;n/=10;}while(i–>=1)data_lcd(c);}pls help meMarch 15, 2013 at 1:57 pm #9321SavioParticipant
Hey Parth,
It would be very helpfull if you could post your code with comments explaining the steps taken by you.
I assume you are using LCD in 4-bit mode. If so, initialize the LCD in 4-bit mode with command 0x02.
I have faced problems using KEIL while using ” #define LCD P0;”. Instead i’ve used “sfr P0=LCD;”.
Hope you solve your problem,
Regards.
March 15, 2013 at 6:49 pm #9324AJISH ALFREDParticipantHi Parth,
Please post your ‘error dialogue’ so that we can have a better idea about the issue.
March 17, 2013 at 4:09 pm #9335ParthParticipanti have one error and warning
warning C206 :- ‘display_lcd’ missing function prototype
erroe C267 :_ ‘display_lcd’ require ANSI-style prototype
March 18, 2013 at 1:51 pm #9340SavioParticipantRegarding warning, you are missing a few function prototypes. Mention all the funtions used in your program before the ‘main()’ funtion. i.e. ” void display_lcd(unsigned char *str);”
Regarding error, this is a code which I usually use,
void display_lcd(unsigned char *str)
{
while(*str!=0)
{
data_lcd(*str);
str++;
}
}
Hope this helps, good Luck.
March 19, 2013 at 5:00 am #9342Gopi.gParticipantHi,
Parth,
I think your program is correct. once check 10 k preset (most important for 2*16 lcd display).
Thanks.
-
AuthorPosts
- You must be logged in to reply to this topic.