I am fairly new to the electronics world but have done some programming a decade or so ago.
I am trying to learn how to operate an LCD without a library to better understand how everything works on a binary level.
I ran across a video while trying to learn how to create custom characters where he was using two basic functions (command() and data()) to do everything. It works for the most part, but when I display the custom character using this method, it clears the display and then displays the character in the first space no matter where the cursor is.
can someone help me? I have played with this for two days now and cant figure it out.
Note it works in another program ive written with the same basic setup only using functions for all commands ( displayOnOff(), functionSet(), clearScreen(); and so on).
I am using an 8 bit shift register with q0-q7 pins from the shift register connected to the corresponding d0-d7 pins on the LCD. The clear pin from the shift register is connect to positive and the oe pin is set negative.
I am new so take it easy pointing out all the newby mistakes. Also apologies in advanced if code is sloppy.
int rsPin=6;
int ePin=5;
int latchPin=11;
int clockPin=9;
int dataPin=12;
int dt1=5;
int dt2=5;
int dt3=5;
byte zero=0x30;
byte middleFinger[]{
0x00,
0x00,
0x04,
0x04,
0x04,
0x0E,
0x1F,
0x0F,
};
byte smileyChar[]{
0x0A,
0x0A,
0x0A,
0x00,
0x11,
0x11,
0x0E,
0x00,
};
void setup() {
// put your setup code here, to run once:
pinMode(rsPin,OUTPUT);
pinMode(ePin,OUTPUT);
pinMode(latchPin,OUTPUT);
pinMode(clockPin,OUTPUT);
pinMode(dataPin,OUTPUT);
delay(dt1);
command(0x38); //0x38 SETS 8 BIT MODE, 2LINES, 5X8 DOT MATRIX
command(0x01); //0x01 clears screen
command(0x0F);//0x0D SETS DISPLAY ON,CURSOR ON, BLINK ON
}
void loop() {
// put your main code here, to run repeatedly:
for(int x=0;x<8;x++){
data(zero);
zero++;
delay(2500);
}
//for(int j=0;j<32;j++){//move cursor to line 2
//command(0x14);
//}
customChar(0x40);
customChar(0x40);
delay(10000);
command(0x01);
zero=0x30;
}
void command(byte myByte){
digitalWrite(rsPin,LOW);
delay(dt1);
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,MSBFIRST,myByte);
digitalWrite(latchPin,HIGH);
digitalWrite(ePin,HIGH);
delay(dt2);
digitalWrite(ePin,LOW);
delay(dt3);
}
void data(byte myByte){
digitalWrite(rsPin,HIGH);
delay(dt1);
digitalWrite(latchPin,LOW);
shiftOut(dataPin,clockPin,MSBFIRST,myByte);
digitalWrite(latchPin,HIGH);
digitalWrite(ePin,HIGH);
delay(dt2);
digitalWrite(ePin,LOW);
delay(dt3);
}
void customChar(byte storage){
command(storage);
for(int i=0;i<8;i++){
data(middleFinger[i]);
}
command(0x01); // this may be my issue. that is the command to clear code but it will not print without it
data(0x00);
}