- #define LCD_DB P0
- sbit LCD_E=P2^0;
- sbit LCD_RW=P2^1;
- sbit LCD_RS=P2^2;
- u8 disp[]=" dripping speed ";
- void LCD_init()
- {
- LCD_write_command(0x38);
- LCD_write_command(0x0c);
- LCD_write_command(0x06);
- LCD_write_command(0x01);
- LCD_write_command(0x80);
- }
- void LCD_write_command(unsigned char com)
- {
- LCD_E=0;
- LCD_RS=0;
- [color=#007000][backcolor=rgb(255, 255, 255)][font=Tahoma,] LCD[/font][/backcolor][/color]_RW=0;
- LCD_DB=com;
- delay(1000);
- LCD_E=1;
- delay(5000)
- LCD_E=0;
- }
- void LCD_write_data(unsigned char dat)
- {
- LCD_E=0;
- LCD_RS=1;
- LCD_RW=0;
- LCD_DB=dat
- delay(1000);
- LCD_E=1
- delay(5000)
- LCD_E=0;
- }
-
- void main()
- {
- u8 i;
- LCD_init();
- for(i=0;i<16;i++)
- {
- LCD_write_data(disp[i]);
- }
- while(1);
- }
复制代码
|