这条lcd1602的C程序怎么总是有错误的?

[复制链接]
查看11 | 回复2 | 2009-8-1 10:39:41 | 显示全部楼层 |阅读模式
/*ShowChar(l++;*(ptr+i))*/;你把这“;”要么拿上去,要么就把/**/给去掉了,“;”那样就不要去了!提示不是说语法错误嘛!
回复

使用道具 举报

千问 | 2009-8-1 10:39:41 | 显示全部楼层
#include#define uchar unsigned char#define uint unsigned intuchar code table[]="I LIKE MCU!";uchar code table1[]="www.TXMCU.COM";sbit lcden=P3^4;sbit lcdrs=P3^5;sbit dula=P2^6;sbit wela=P2^7;uchar num;void delay(uint z){ uint x,y; for(x=z;x>0;x--)for(y=110;y>0;y--);}void write_com(uchar com){ lcdrs=0; P0=com; delay(5); lcden=1; delay(5); lcden=0;}void write_data(uchar date){ lcdrs=1; P0=date; delay(5); lcden=1; delay(5); lcden=0;}void init(){ dula=0; wela=0; lcden=0; write_com(0x38); write_com(0x0e); write_com(0x06); write_com(0x01); write_com(0x80+0x10);}void main(){ init(); for(num=0;num<11;num++) {write_data(table[num]);delay(20); }// write_com(1); write_com(0x80+0x53); for(num=0;num<13;num++) {write_data(table1[num]);delay(20); } for(num=0;num<16;num++) {write_com(0x18);delay(20); } while(1);}这是郭天翔教程上的例程自己看下,用的也是1602,不知有用没。
回复

使用道具 举报

千问 | 2009-8-1 10:39:41 | 显示全部楼层
void ShowString(unsigned char line,unsigned char *ptr){unsigned char l,i;l=line*0x10;for(i=0;i<16;i++)showchar(l++,*(ptr+i));}/*******ptr类型声明有问题吧,还有showchar两个参数之间要用逗号,要全小写,跟上面的保持一致,指针变量ptr要明确声明unsigned char *ptr,还有,如果你的字符串不够16个这样就不太好吧,改一下吧:*****/void ShowString(unsigned char line,unsigned char *ptr){unsigned char l,i;l=line*0x10;while(*ptr) {showchar(l,*ptr); l++;ptr++;} }
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行