📄 8_bit_character_c.txt
字号:
//---------------------------------------------------------
/*
8_bit_character.c
Program for writing to Newhaven Display character LCD
(c)2008 Curt Lagerstam - Newhaven Display International, LLC.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
*/
//---------------------------------------------------------
#include <at89x51.h>
//---------------------------------------------------------
/*
#define E P3_4;
#define D_I P3_0;
#define R_W P3_7;
*/
volatile xdata at 0xB4 char E;
volatile xdata at 0xB0 char D_I;
volatile xdata at 0xB7 char R_W;
char const text1[] = {"Newhaven Display"};
char const text2[] = {"Character LCD "};
void Delayms(int n){
int i;
int j;
for (i=0;i<n;i++)
for (j=0;j<1000;j++)
{;}
}
void command(char i){
P1 = i;
P3_0 =0;
P3_7 =0;
P3_4 = 1;
Delayms(1);
P3_4 = 0;
}
void write(char i){
P1 = i;
P3_0 =1;
P3_7 =0;
P3_4 = 1;
Delayms(1);
P3_4 = 0;
}
void init(){
E = 0;
Delayms(5);
command(0x30);
Delayms(100);
command(0x30);
Delayms(10);
command(0x30);
Delayms(10);
command(0x38);
command(0x10);
command(0x0c);
command(0x06);
}
void home(){
command(0x01);
Delayms(5);
}
void nextline(){
command(0xc0);
}
void disp_pic(){
int i;
home();
for (i=0;i<16;i++){
write(text1[i]);
}
nextline();
for (i=0;i<16;i++){
write(text2[i]);
}
}
void main(void) {
P1=0;
P3=0;
while(1){
init();
disp_pic();
Delayms(1000);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -