Newhaven Display Forum

Newhaven Products => Character LCDs => Topic started by: fraryb on May 06, 2015, 08:53:00 AM

Title: NHD-C0220BiZ-FSW-FBW-3V3M I2C not working.
Post by: fraryb on May 06, 2015, 08:53:00 AM
Having problem getting display to respond to I2C commands.  Changed pullups over range from 27k down to 4.7k ohms and over 400kHz down to 10kHz without success. Can get response to enumeration query only when 3.3 volt supply is removed (open circuit).  Using generic I2C arduino code as well as that from datasheet.  Any help will be greatly appreciated.
Title: Re: NHD-C0220BiZ-FSW-FBW-3V3M I2C not working.
Post by: Paul_B on May 06, 2015, 10:32:35 AM
Hello Fraryb,

Below is some example code for that display written for the Arduino  ;)

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

int RES = 22;
int ASDA = 20;
int ASCL = 21;

unsigned char text1[]={"  Newhaven Display  "};
unsigned char text2[]={" Clear Display Test "};
unsigned char text3[]={"   March 27, 2014   "};
unsigned char text4[]={"   Michael LaVine   "};

const char slave2w = 0x3C;  //3E for CiZ (0x7C shifted over 1 bit)  //3C for BiZ (0x78 shifted over 1 bit)
const char comsend = 0x00;
const char datasend = 0x40;
const char line2 = 0xC0;

void show(unsigned char *text)
{
  int n, d;
  d=0x00;
  Wire.beginTransmission(slave2w);
  Wire.write(datasend);
  for(n=0;n<20;n++)
  {
    Wire.write(*text);
    ++text;
  }
  Wire.endTransmission();
}

void nextline(void)
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(line2);
  Wire.endTransmission();
}

void cleardisplay(void)
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x01);
  Wire.endTransmission();
}

void CiZ_init()
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x39);
  delay(1);
  Wire.write(0x14);
  Wire.write(0x70);
  Wire.write(0x5E);
  Wire.write(0x6D);
  Wire.write(0x0C);
  Wire.write(0x01);
  Wire.write(0x06);
  Wire.endTransmission();
}

void setup()
{
  pinMode(RES, OUTPUT);
  pinMode(ASCL, OUTPUT);
  pinMode(ASDA, OUTPUT);
  digitalWrite(RES, HIGH);
  //delay(10);
  //digitalWrite(ASCL, LOW);
  //digitalWrite(ASDA, LOW);
  //delay(10);
  Wire.begin();
  delay(10);
  CiZ_init();
  delay(5);
}

void loop()
{
  show(text1);
  nextline();
  show(text2);
  delay(1500);
  cleardisplay();
  delay(2);

  show(text3);
  nextline();
  show(text4);
  delay(1500);
  cleardisplay();
  delay(2);
}

Finally double check that your connections are correct, see page 4 in the displays datasheet.

http://www.newhavendisplay.com/specs/NHD-C0220BiZ-FSW-FBW-3V3M.pdf

Please keep us posted on your progress!