Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - dalemoore

Pages: [1]
1
I have scoured this forum and the example code provided by NewHaven for longer than I'd like to admit and I'm unable to get the titled graphic LCD working with an ArduinoPro Mini 3.3V.

I'm using SPI to communicate with the LCD.  At one time, I was able to turn on all of the pixels (so I know the device is working), but I couldn't control individual pixels.  I've since stitched together, what I hope, is a simple to read program from the various posts on this forum as well as NewHaven's examples.  Ideally, I'd just like to see something appear on the LCD that I actually put there and I think I can figure out the rest. 

My Arduino to LCD pin connections are as follows (I've used the standard Arduino SPI connections to avoid problems).
PIN Connections
  • Arduino PIN 10 (CS or SS) connected to PIN 6 on display
  • Arduino PIN 11 (MOSI) connected to PIN 2 on display
  • Arduino PIN 12 (MISO) not used
  • Arduino PIN 13 (SCK or CLOCK) connected to PIN 1 on display
  • Arduino PIN VCC connected to PIN 3 and 7 on display for + power
  • Arduino PIN 8 connected to PIN 5 (RESET) on display.  Set to LOW to reset the display
  • Arduino PIN 9 connected to PIN 4 (A0) on display for register selector (0:instruction, 1:data)
  • Arduino PIN GND connected to PINs (7 and 10) for grounds

The Arduino is connected to my computer's USB port through an FTDI Basic (Sparkfun).  I've done other Arduino projects in this manner, including SPI communications, and haven't had any issues.

Here's the code that I've been working with.  Like I mentioned, anything that jumps out to anyone as a potential problem I would really love to hear.  Thank you.

Code: [Select]
#include <SPI.h>
// PIN Connections
// Arduino PIN 10 (CS or SS) connected to PIN 6 on display
// Arduino PIN 11 (MOSI) connected to PIN 2 on display
// Arduino PIN 12 (MISO) not used
// Arduino PIN 13 (SCK or CLOCK) connected to PIN 1 on display
// Arduino PIN VCC connected to PIN 3 and 7 on display for + power
// Arduino PIN 8 connected to PIN 5 (RESET) on display.  Set to LOW to reset the display
// Arduino PIN 9 connected to PIN 4 (A0) on display for register selector (0:instruction, 1:data)
// Arduion PIN GND connected to PINs (7 and 10) for grounds
#define RESET       8 
#define AZERO       9 
                       
int loopCounter = 0;  // used for debugging

void setup() { 
  // Open the serial debugging port
  Serial.begin(115200); 
  Serial.println("Begin LCD test"); 
  // initialize pin configurations on Arduino
  pinMode(MOSI, OUTPUT);
  pinMode(MISO, INPUT);
  pinMode(SS,OUTPUT);
  pinMode(RESET, OUTPUT); 
  pinMode(AZERO, OUTPUT); 
  // Reset the LCD
  digitalWrite(SS, LOW);      // enable the device
  digitalWrite(RESET, LOW);   // reset active   
  digitalWrite(RESET, HIGH);  // reset inactive
  delay(1000); 
  digitalWrite(SS, HIGH);  // disable the device
  // Start API communications   
  SPI.begin(); 
  SPI.setClockDivider(SPI_CLOCK_DIV128);  // Slowest speed
  SPI.setBitOrder(MSBFIRST);
  delay(200); 
  // Send instructions to LCD for setup
  initializeLcd();
  delay(50); 
}

void writeCommand(char bits) {
  digitalWrite(SS,LOW);    // chip select 
  digitalWrite(AZERO, LOW); 
  SPI.transfer(bits);       
  digitalWrite(SS,HIGH);    // chip deselect
}

void writeData(char bits) {
  digitalWrite(SS,LOW);    // chip select 
  digitalWrite(AZERO, HIGH); 
  SPI.transfer(bits); 
  digitalWrite(SS,HIGH);    // chip deselect
}

void initializeLcd() {
  writeCommand(0b10100010);  // 0xA2 - LCD bias set to 1/9
  writeCommand(0b10100000);  // 0xA0 1010 0000,  - ADC select in normal mode
  writeCommand(0b11000000);  // 0xC0 COM scan direction = normal
  writeCommand(0b00100101);  // 0x25 resistor ratio
  writeCommand(0b10000001);  // 0x81 electronic volume mode set
  writeCommand(0b00010101);  // 0x15 electronic volume register set
  writeCommand(0b00101111);  // 0x2F operationg mode
  writeCommand(0b01000000);  // 0x40 start line set
  writeCommand(0b10101111);  // 0xAF display on
}

void loop() {   
  Serial.print("loop: ");
  Serial.println(loopCounter++); 
  unsigned int i, j;
  unsigned char page=0xB0;
  for(i=0;i<8;i++)             // fill display with checkerboard pattern
  {
    writeCommand(0x10);        //set column address
    writeCommand(0x00);        //set column address
    writeCommand(page);        //set page address
    for(j=0;j<64;j++)
    {
      writeData(0xAA);
      writeData(0x55);
    }
    page++;
  } 
  delay(2000);
}



Pages: [1]