就下面几段程序,LCD2004A只用了高四位,时序和1602一样,延迟时间改了好多变了,怎么就是调不通,电路管脚、电源校验过,郁闷,看到蓝屏就头大,谁有没有源码,参考一下,说实话Arduino用起来真别扭。。。
- char LCD7=29;
- char LCD6=27;
- char LCD5=25;
- char LCD4=23;
- char LCDE=17;
- char LCDRS=16;
- void Lcd2004A_WriteCom(char cmd){
-
- char temp=(cmd&0x0f)<<4;
-
- digitalWrite(LCD7,cmd & 0x80);
- digitalWrite(LCD6,cmd & 0x40);
- digitalWrite(LCD5,cmd & 0x20);
- digitalWrite(LCD4,cmd & 0x10);
-
- digitalWrite(LCDE,LOW);
- digitalWrite(LCDRS,LOW);
- delay(1);//1ms
- digitalWrite(LCDE,HIGH);
- delay(20);//20ms
- digitalWrite(LCDE,LOW);
-
- digitalWrite(LCD7,temp & 0x80);
- digitalWrite(LCD6,temp & 0x40);
- digitalWrite(LCD5,temp & 0x20);
- digitalWrite(LCD4,temp & 0x10);
-
- delay(1);
- digitalWrite(LCDE,HIGH);
- delay(20);
- digitalWrite(LCDE,LOW);
- delay(1);
- }
- void Lcd2004A_WriteDat(char data){
-
- char temp=(data&0x0f)<<4;
-
- digitalWrite(LCD7,data & 0x80);
- digitalWrite(LCD6,data & 0x40);
- digitalWrite(LCD5,data & 0x20);
- digitalWrite(LCD4,data & 0x10);
-
- digitalWrite(LCDE,LOW);
- digitalWrite(LCDRS,HIGH);
- delay(1);
- digitalWrite(LCDE,HIGH);
- delay(20);
- digitalWrite(LCDE,LOW);
- digitalWrite(LCD7,temp & 0x80);
- digitalWrite(LCD6,temp & 0x40);
- digitalWrite(LCD5,temp & 0x20);
- digitalWrite(LCD4,temp & 0x10);
-
- delay(1);
- digitalWrite(LCDE,HIGH);
- delay(20);
- digitalWrite(LCDE,LOW);
- delay(1);
- }
- void InitLCD2004(){
- pinMode(LCD7,OUTPUT);
- pinMode(LCD6,OUTPUT);
- pinMode(LCD5,OUTPUT);
- pinMode(LCD4,OUTPUT);
- delay(5);
- Lcd2004A_WriteCom(0x32);
- delay(5);
- Lcd2004A_WriteCom(0x28);
- delay(5);
- Lcd2004A_WriteCom(0x06);
- delay(5);
- Lcd2004A_WriteCom(0x0c);
- delay(5);
- Lcd2004A_WriteCom(0x80);
- delay(5);
- Lcd2004A_WriteCom(0x01);
- delay(5);
- }
- void setup() {
- delay(5);
- InitLCD2004();
- SetLCD2004_Win(1,0);
- }
- void loop() {
- Lcd2004A_WriteCom(0x01);
- delay(5);
- Lcd2004A_WriteDat("a");
- }
复制代码
此帖出自
小平头技术问答
一周热门 更多>