}:  [ӡ]

: liumin    rg: 2013-8-6 11:22
}: 
λIICҺʾһcҲҬF(xin)ڸǟoְƶ˿RS,RW,EN֪Ǻ
: xiao1074234390    rg: 2013-8-6 12:29
RS=1nj(sh)(j)RS=0njַRW=1Һx(sh)(j)RW=0Һ(sh)(j)Eʹ
ַ@ӣ
          RS=0;
         delay(5);//t5ms
         P2=com;  //ַcom
         EN=1;
         delay(5);
         EN=0;
(sh)(j)RS=1;׃
ַҪҺf
: liumin    rg: 2013-8-6 14:42
@NеҲ҆ǴҺģIICһֻЃɗlSDASCL
: admin    rg: 2013-8-6 15:15
@д𰸣http://www.torrancerestoration.com/mcu/2036.html
: liumin    rg: 2013-8-6 21:20
admin l(f) 2013-8-6 15:15
@д𰸣http://www.torrancerestoration.com/mcu/2036.html

@njLCD1602ֱӾӵĿƽӿRSR/WEȻľУЛ]IIC鴮·D@ӵӵĽӿֻvcc,GND,SCL,SDAĂ߀ǺܸxoҲنl(f)
: liumin    rg: 2013-8-6 21:22
ҵǂIICҺǻArduino51ƬC
: liumin    rg: 2013-8-7 17:28
IICҺѽ(jng)cˣ߀ܺܺõĿƣo҅һ£
#include <reg52.h>
#include "intrins.h"
#define uint  unsigned int
#define uchar unsigned char
sbit SCL=P2^1;
sbit SDA=P2^0;
//ӕr(sh)
void delayus()
{
        ;;;;;
}
void delayms(uchar x)
{
        uchar j;
        while(x--)
                for(j=110;j>0;j--);
}
//_ʼ̖
void iic_start(void)
{
        SDA = 1;
        delayus();
    _nop_();_nop_();_nop_();_nop_();_nop_();
        SCL = 1;
        delayus();
        SDA=0;
        delayus();
}
//ֹ̖ͣ
void iic_stop(void)
{
        SDA = 0;
        delayus();
        SCL = 1;
        delayus();
        SDA = 1;
        delayus();
}
//ʼ
void iicinit(void)
{       
        SDA = 1;
        delayus();
        SCL=1;
        delayus();
}
//(yng)
void respons(void)
{
        uchar i=0;
        SCL = 1;
        delayus();
        while((SDA=1)&&(i<255))
                i++;
        SCL = 0;
        delayus();
}
//l(f)һֹ(ji)
void write_byte(uchar date)
{
        uchar i,temp;
        temp=date;                                                       
        for(i=0;i<8;i++)
        {
                temp=temp<<1;                                                        
                SCL = 0;
                delayus();
                SDA=CY;
                delayus();
                SCL = 1;
                delayus();       
        }
        SCL=0;
        delayus();
        SDA=1;
        delayus();
}
//ַ(sh)(j)
void write_lcd(uchar contr1,uchar contr2,uchar date1,uchar date2)
{
        iic_start();
        write_byte(0x4e);                                               
        respons();
        write_byte(contr1);
        write_byte(contr2);
        respons();
        delayms(5);
        write_byte(date1);
        write_byte(date2);
        respons();
        iic_stop();
}
void lcd_init()
{
        write_lcd(0x3c,0x8c,0xf8,0xf8);       
        write_lcd(0x0c,0xcc,0xf8,0xf8);       
        write_lcd(0x0c,0x6c,0xf8,0xf8);       
        write_lcd(0x0c,0x1c,0xf8,0xf8);       
}
void main()
{
        iicinit();
        lcd_init();
        while(1)
        {
                write_lcd(0xfc,0x0c,0xf8,0x08);                //Ȍַ
                write_lcd(0x4d,0x3d,0x48,0x38);                //(sh)(j)
                write_lcd(0x4d,0x4d,0x48,0x48);                //(sh)(j)
                write_lcd(0xad,0x0d,0xa8,0x08);                //(sh)(j)
        }
}

: liumin    rg: 2013-8-7 17:29
ڰٶIICҺԭv⣡
: α919    rg: 2013-8-7 17:34
IICӿڵķʽ




gӭR (http://www.torrancerestoration.com/bbs/) Powered by Discuz! X3.1