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 - simonp54

Pages: [1]
1
Graphic LCDs / NHD-C12864B2Z-RN-FBW Arduino Uno
« on: March 18, 2014, 03:59:49 PM »
Hello again...
After this board has had all its content dropped, I thought I should post again to see if you can help me further.
As you know I am struggling to get this screen to work.  I am now using an I2C I/O expander and two 4050 chips to do the logic conversion to 3.3V I have debugged the outputs using LEDs and I am confident that the code which I attach is sending the correct stuff to the interface (through a NHD-FFC28).  I have checked and double checked everything and still I get nothing from the screen.  When I test without the screen connected it all looks correct, when the screen is inserted into the FFC28 the LEDs dont flash the same way at all...
I am using capacitors from Farnell part number (8126933).

Code is as follows:
Code: [Select]
#include <Wire.h>

#define IO_I2C_ADDR 0x20
#define IO_DIRA_REG 0x00
#define IO_DIRB_REG 0x01
#define IO_ALL_OUTPUTS 0x00
#define IO_ALL_INPUTS 0xFF
#define IO_ADDR_PORT_A 0x12
#define IO_ADDR_PORT_B 0x13

#define RD_PIN 4
#define WR_PIN 3
#define A0_PIN 2

void writeCom(byte bits)
{
  digitalWrite( A0_PIN, LOW );     // A0 - set LOW
  digitalWrite( RD_PIN, HIGH );    // aka E - set HIGH
  digitalWrite( WR_PIN, LOW );     // aka RW - set LOW

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();

  digitalWrite( RD_PIN, LOW );    // aka E - set LOW
  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
}

void writeData(byte bits)
{
  digitalWrite( A0_PIN, HIGH );    // A0 - set HIGH
  digitalWrite( WR_PIN, LOW );     // aka RW - set LOW
  digitalWrite( RD_PIN, HIGH );    // aka E - set HIGH
 
  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_ADDR_PORT_A);              // address port A
  Wire.write(bits);
  Wire.endTransmission();
 
  digitalWrite( RD_PIN, LOW );    // aka E - set LOW
  digitalWrite( WR_PIN, LOW );    // aka RW - set LOW
}



void initScreen()
{
  digitalWrite( WR_PIN, LOW );      // aka RW - set RW to LOW
  digitalWrite( A0_PIN, LOW );      // aka RS - set RS to LOW
                                    // RESTB ?aka RST? - wired to VDD
                                    // CS1B - wired to VSS
  digitalWrite( RD_PIN, LOW );      // aka E - set E to LOW
  delay(22);                        //wait 22ms

  writeCom( 0xA2 );    // 1/9 bias
  writeCom( 0xA0 );    // ADC SELECT NORMAL
  writeCom( 0xC8 );    // COM OUTPUT REVERSE
  writeCom( 0xA4 );    // DISPLAY ALL POINTS NORMAL
  writeCom( 0x40 );    // DISPLAY START LINE SET
  writeCom( 0x25 );    // INTERNAL RESISTOR RATIO
  writeCom( 0x81 );    // ELECTRONIC VOLUME MODE SET
  writeCom( 0x10 );    // ELECTRONIC VOLUME
  writeCom( 0x2F );    // POWER CONTROLLER SET
  writeCom( 0xAF );    // DISPLAY ON
}

//***************************************************
//The setup() function is called
//when a sketch starts. Use it to
//initialize variables, pin modes,
//start using libraries, etc. The
//setup function will only run once,
//after each powerup or reset of the Arduino board.
//***************************************************
void setup()
{
  Serial.begin(9600);

  Wire.begin();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRA_REG);              // IDDIRA register
  Wire.write(IO_ALL_OUTPUTS);              // set all port A to outputs
  Wire.endTransmission();

  Wire.beginTransmission(IO_I2C_ADDR);
  Wire.write(IO_DIRB_REG);              // IDDIRB register
  Wire.write(IO_ALL_OUTPUTS);              // set all port B to outputs
  Wire.endTransmission();
 
  pinMode( WR_PIN, OUTPUT );    // aka RW
  pinMode( A0_PIN, OUTPUT );    // aka RS
  pinMode( RD_PIN, OUTPUT );    // aka E
 
  initScreen(); 
}


//***************************************************
//the loop() function does precisely what its name suggests,
//and loops consecutively, allowing your program to change
//and respond. Use it to actively control the Arduino board.
//***************************************************
void loop()
{
  writeCom( B10100110 );
  delay(1000);
  writeCom( B10100111 );
  delay(1000);
}

Pages: [1]