So I'm trying to hook up this LCD to my Nano.
I've double checked all my connections and everything appears correct. however I can't get it to even turn on. After rechecking my connections I realized that while I have 3.3 going to the power for the chip, all the SPI lines are running at 5V because that's what the Nano runs at. So is it possible I fried my board by doing that? Or is that ok? Here's my code. I based it on a few different examples I've seen, but I feel quite confident that I screwed something up in it. It doesn't even seem like it's turning the board on. I don't know what it would do when it turned on, but I sorta feel like I'd see SOMETHING happen, even if it wasn't printing the data properly to the display.
#define RE 17
#define CS 6
#define SC 7
#define SI 8
int serialcounter = 1;
#define RS 5
void setup()
//initialize the LCD
{
pinMode(RE, OUTPUT);
pinMode(RS, OUTPUT);
pinMode(CS, OUTPUT);
pinMode(SC, OUTPUT);
pinMode(SI, OUTPUT);
digitalWrite(CS, HIGH);
digitalWrite(RS, HIGH);
initLCD();
}
void initLCD(){
digitalWrite(RE,LOW);
delay(2);
digitalWrite(RE,HIGH);
delay(20);
digitalWrite(RS, LOW);
digitalWrite(CS, LOW);
spi_transfer(B00110000);
delay(2);
spi_transfer(B00110000); //wake up
spi_transfer(B00110000); //wake up
spi_transfer(B00111001); //function set
spi_transfer(B00010100); //internal osc frequency
spi_transfer(B01010110); //power control
spi_transfer(B01101101); //follower control
spi_transfer(B01110000); //contrast
spi_transfer(B00001100); //display on
spi_transfer(B00000110); //entry mode
spi_transfer(B00000001); //clear
delay(10);
digitalWrite(CS, HIGH);
}
void spi_transfer(int data) {
digitalWrite(CS, LOW);
digitalWrite(RS, HIGH);
shiftOut(SI,SC,MSBFIRST,data);
digitalWrite(CS, HIGH);
}
void clearDisplay() {
digitalWrite(CS,LOW);
digitalWrite(RS,LOW);
//clear the display
spi_transfer(B00000001); //clear
digitalWrite(RS,HIGH);
digitalWrite(CS,HIGH);
}
void loop(){
spi_transfer(B00000001);
digitalWrite(13, HIGH);
delay(1000);
clearDisplay();
digitalWrite(13, LOW);
delay(1000);
}