本人菜鸟,请各位高手指出我程序中的错误,谢谢!

2019-03-24 19:43发布

#include <reg51.h>

#define uchar unsigned char
#define unit unsigned int

sbit rs=P2^6;
sbit rw=P2^5;
sbit  e=P2^7;

uchar table1[]=        "welcome!" ;
uchar table2[]=        "1234567890123456";

//************************************
void delay (unit t)
{
    uchar j;
           for(t>0;t--)
       for(j=125;j>0;j--);
}


//write com***************************
void write_com(uchar com)
{
    e=0;
    rs=0;
    rw=0;
    P0=com;
    delay(1);
    e=1;
    delay(1);
    e=0;
}
//write dat***************************
void write_dat(uchar dat)
{
    e=0;
    rs=1;
    rw=0;
    P0=dat;
    delay(1);
    e=1;
    delay(1);
    e=0;
}


void main();
{
           uchar j;
    init();
    write_com(0x80);
    for(j=0;j<16;j++);
        {
           write_dat(table1[j]);
           delay(1);
        }
        write_com(0x80+0x40);
        for(j=0;j<16;j++);
        {
           write_dat(table2[j]);
           delay(1);
        }
}

//LCD初始化***************************
void init()
{
    delay (15);
    write_com(0x38);
        delay(5);
        write_com(0x38);
        delay(5);
        write_com(0x38);
        write_com(0x38);
        write_com(0x01);
        write_com(0x06);
        write_com(0x0c);
}


编译出现
LCD.C(17): error C141: syntax error near ')'
LCD.C(49): error C141: syntax error near '{'
LCD.C(52): error C141: syntax error near '0x80'
LCD.C(52): error C231: '_write_com': redefinition
LCD.C(53): error C141: syntax error near 'for'
LCD.C(53): error C141: syntax error near '=', expected ')'
LCD.C(53): error C129: missing ';' before '<' 此帖出自小平头技术问答
友情提示: 此问题已得到解决,问题已经关闭,关闭后问题禁止继续编辑,回答。