Author Topic: I2C on NHD-C0216CiZ-FSW-FBW-3V3  (Read 3680 times)

SteveS

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
I2C on NHD-C0216CiZ-FSW-FBW-3V3
« on: August 15, 2014, 05:56:47 AM »
I am interfacing a NHD-C0216CiZ-FSW-FBW-3V3 serial I2C display to an Intel Galileo Arduino (set to 3.3V operation) but have not been ale to get any response from the display. In order to reduce the variables on what could be going wrong, does anyone have suitable sample code for this 2 wire serial interface - eg to initalise and write something on the screen?
Thanks,
Steve

Michael_L

  • Administrator
  • Hero Member
  • *****
  • Posts: 356
  • Karma: 33
    • View Profile
Re: I2C on NHD-C0216CiZ-FSW-FBW-3V3
« Reply #1 on: August 15, 2014, 10:33:53 AM »
I have some Arduino code for this display below:

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

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

int test = 55;

unsigned char text1[]={"Newhaven Display"};
unsigned char text2[]={"    I2C TEST    "};
unsigned char text3[]={" March 21 2014  "};
unsigned char text4[]={" Michael LaVine "};

const char slave2w = 0x3E;  //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<16;n++)
  {
    Wire.write(*text);
    ++text;
  }
  Wire.endTransmission();
}

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

void CGRAM(void)
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x38);
  Wire.write(0x40);
  Wire.endTransmission();
  delay(10);
  Wire.beginTransmission(slave2w);
  Wire.write(datasend);
  Wire.write(0x00);
  Wire.write(0x1E);
  Wire.write(0x18);
  Wire.write(0x14);
  Wire.write(0x12);
  Wire.write(0x01);
  Wire.write(0x00);
  Wire.write(0x00);
  Wire.endTransmission();
}

void CiZ_init()
{
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x38);
  delay(10);
  Wire.write(0x39);
  delay(10);
  Wire.write(0x14);
  Wire.write(0x70);
  Wire.write(0x5E);
  Wire.write(0x6D);
  Wire.write(0x0C);
  Wire.write(0x01);
  Wire.write(0x06);
  Wire.endTransmission();
 
  CGRAM();
 
  Wire.beginTransmission(slave2w);
  Wire.write(comsend);
  Wire.write(0x39);
  Wire.write(0x01);
  test = Wire.endTransmission();
  Wire.endTransmission();
  if(test!=0)
  {
    while(1)
    {
      delay(100);
    }
  }
  delay(10);
}

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

void loop()
{
 
  Wire.begin();
  //TWBR = 12;
  //TWSR |= _BV(TWPS0);
  while(1)
  {
  CiZ_init();
  show(text1);
  nextline();
  show(text2);
  delay(1000);
 
  CiZ_init();
  show(text3);
  nextline();
  show(text4);
  delay(1000);
  }
}

SteveS

  • Newbie
  • *
  • Posts: 2
  • Karma: 0
    • View Profile
Re: I2C on NHD-C0216CiZ-FSW-FBW-3V3
« Reply #2 on: August 19, 2014, 05:37:31 AM »
Thanks for your help Michael - I will give it a try.
Regards,
Steve

 

NHD-C0216CIZ-FSW-FBW-3V3 unexpected I2C levels

Started by kentavvBoard Character LCDs

Replies: 3
Views: 2472
Last post April 30, 2016, 06:13:19 PM
by perky
NHD-C0216CiZ-FSW-FBW-3V3 with arduino nano

Started by litunBoard Character LCDs

Replies: 3
Views: 314
Last post September 21, 2017, 08:03:24 AM
by Saurabh_B
NHD-C0216CIZ Not Acknowledging

Started by danbujakBoard Character LCDs

Replies: 7
Views: 3442
Last post February 23, 2015, 08:16:16 AM
by Michael_L
NHD-C0216CiZ-FSW-FBW-3V3 not working

Started by gab_electroBoard Character LCDs

Replies: 1
Views: 865
Last post October 21, 2016, 03:09:51 PM
by Saurabh_B
Using NHD-C0216CiZ-FSW-FBW-3V3 on I2C on Linux

Started by ABSysacomBoard Character LCDs

Replies: 0
Views: 801
Last post November 08, 2016, 03:56:00 PM
by ABSysacom