#define SCLK 3
#define SDIN 4
#define DC 5
#define RST 6
#define SCE 7
void setup()
{
pinMode(SCLK, OUTPUT);
digitalWrite(SCLK, 0);
pinMode(SDIN, OUTPUT);
digitalWrite(SDIN, 0);
pinMode(DC, OUTPUT);
digitalWrite(DC, 0);
pinMode(RST, OUTPUT);
digitalWrite(RST, 1);
pinMode(SCE, OUTPUT);
digitalWrite(SCE, 1);
//Reset
digitalWrite(SCE, LOW);
digitalWrite(RST, LOW);
delay(10);
digitalWrite(RST, HIGH);
digitalWrite(SCE, HIGH);
//Tell LCD that extended commands follow
digitalWrite(DC, LOW);
digitalWrite(SCE, LOW);
shiftOut(SDIN, SCLK, MSBFIRST, 0x21);
digitalWrite(SCE, HIGH);
//Set LCD Vop (Contrast)
digitalWrite(DC, LOW);
digitalWrite(SCE, LOW);
shiftOut(SDIN, SCLK, MSBFIRST, 0xA0);
digitalWrite(SCE, HIGH);
//Set Temp coefficent
digitalWrite(DC, LOW);
digitalWrite(SCE, LOW);
shiftOut(SDIN, SCLK, MSBFIRST, 0x04);
digitalWrite(SCE, HIGH);
//LCD bias mode 1:48
digitalWrite(DC, LOW);
digitalWrite(SCE, LOW);
shiftOut(SDIN, SCLK, MSBFIRST, 0x14);
digitalWrite(SCE, HIGH);
//We must send 0x20 before modifying the display control mode
digitalWrite(DC, LOW);
digitalWrite(SCE, LOW);
shiftOut(SDIN, SCLK, MSBFIRST, 0x20);
digitalWrite(SCE, HIGH);
//Set display control
digitalWrite(DC, LOW);
digitalWrite(SCE, LOW);
shiftOut(SDIN, SCLK, MSBFIRST, 0x0C); //0D = Inverted mode
digitalWrite(SCE, HIGH);
delay(3000);
for (int index = 0 ; index < (84 * 48 / 8) ; index++){
digitalWrite(DC, HIGH);
digitalWrite(SCE, LOW);
int i=0;
int pinState;
digitalWrite(SCLK, 0);
digitalWrite(SDIN, 0);
for (i=7; i>=0; i--) {
digitalWrite(SCLK, 0);
if ( 0x55 & (1<<i) ) {
pinState= 1;
}
else {
pinState= 0;
}
//Sets the pin to HIGH or LOW depending on pinState
digitalWrite(SDIN, pinState);
//register shifts bits on upstroke of clock pin
digitalWrite(SCLK, 1);
delay(1);
//zero the data pin after shift to prevent bleed through
digitalWrite(SDIN, 0);
}
shiftOut(SDIN, SCLK, MSBFIRST, 0x55);
digitalWrite(SCE, HIGH);
}
digitalWrite(DC, 0);
}
void loop(){
}