I just bought an LCD. I connected everything as explained in this sheet.
This is the code I am using:
#define RST 3
#define CE 2
#define DC 4
#define DIN 6
#define CLK 5
void LcdWriteCmd(byte cmd) {
digitalWrite(DC, HIGH); //DC pin is low for commands
digitalWrite(CE, HIGH);
shiftOut(DIN, CLK, MSBFIRST, cmd); //transmit serial data
digitalWrite(CE, LOW);
}
void setup() {
pinMode(RST, OUTPUT);
pinMode(CE, OUTPUT);
pinMode(DC, OUTPUT);
pinMode(DIN, OUTPUT);
pinMode(CLK, OUTPUT);
digitalWrite(RST, LOW);
digitalWrite(RST, HIGH);
LcdWriteCmd(0xAE); // LCD set display enabled
LcdWriteCmd(0x21); // LCD set power COntrol
LcdWriteCmd(0x14); // LCD bias mode 1:40
LcdWriteCmd(0xA2); // LCD basic commands
LcdWriteCmd(0xA9); // LCD all segments on
}
void loop() {
}
The commands I used are in the command table of this sheet. (page 12) It is supposed to turn all pixels on now. However nothing happens. All pixels are staying off.
Can you see a problem?
LcdWriteCmd
you set it high, send the command and then set it low, try swapping that to low, send command, high. Also when you set reset low then high maybe add a short pause in there. A millisecond or less would be fine, just something to add a tiny delay. And maybe double check that your LCD has an active low reset not active high, if it's being held in reset then nothing will show up, active low is more common but isn't guaranteed. – Andrew Dec 6 '16 at 10:41