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 - 0miker0

Pages: [1]
1
For some reason my i2c display appears to be missing random characters. I've adjusted the i2c speed and delays but characters are still missing. It's connected to a new Arduino UNO. I'm not sure if the Uno has built in pull-up resistors on the SDA & SCL lines but the display has onboard 10K pull-ups.

On the screen now I see:
124679
BCEGHJLMOQRT

and my code is:

Code: [Select]
/*
 
Newhaven NHD-0420D3Z-NSW-BBW-V3 LCD
R1 shorted with a 0R resistor
SCL and SDA pullup resistors already on LCD

*/
#include <Wire.h>

#define I2C_ADDRESS        0x28  //LCD I2C address  0x28??? It should be 0x50
#define DISPLAY_ON         0x41  //DISPLAY ON
#define DISPLAY_OFF        0x42  //DISPLAY OFF
#define SET_CURSOR         0x45  //SET CURSOR
#define CURSOR_HOME        0x46  //CURSOR HOME
#define MOVE_CURSOR_LEFT   0x49  //MOVE CURSOR LEFT
#define MOVE_CURSOR_RIGHT  0x4A  //MOVE CURSOR RIGHT
#define BLINK_CURSOR_ON    0x4B  //BLINK CURSOR ON
#define BLINK_CURSOR_OFF   0x4C  //BLINK CURSOR OFF
#define BACKSPACE          0x4E  //BACKSPACE
#define CLEAR_SCREEN       0x51  //CLEAR SCREEN
#define SET_CONTRAST       0x52  //SET CONTRAST
#define SET_BACKLIGHT      0x53  //SET BACKLIGHT
#define MOVE_DISP_LEFT     0x55  //MOVE DISPLAY LEFT
#define MOVE_DISP_RIGHT    0x56  //MOVE DISPLAY RIGHT
#define DISP_I2C_ADDR      0x72  //DISPLAY I2C ADDRESS

void setup()
{
  Wire.setClock(100000);  //sets I2C speed to 100kHz
  Wire.begin();
  Serial.begin(9600);
  delay(1000);

  Display_Clear();
  //Cursor_Home();
 
  Set_Cursor_Line_1();
  Wire.beginTransmission(I2C_ADDRESS); 
  Wire.write(0xFE);           //Prefix
  Wire.write("0123456789");  //Display Text
  Wire.endTransmission();

  Set_Cursor_Line_2();
  Wire.beginTransmission(I2C_ADDRESS); 
  Wire.write(0xFE);           //Prefix
  Wire.write("ABCDEFGHIJKLMNOPQRST");  //Display Text
  Wire.endTransmission();
 
  delay(1000);                //wait for a second
}


void loop()
{
 
}



void Display_On(void)
{
 Wire.beginTransmission(I2C_ADDRESS); 
 Wire.write(0xFE);           //Prefix
 Wire.write(DISPLAY_ON);     //Display On
 Wire.endTransmission();
 delay(2);                 //wait for a 1/4 second
}

void Display_Clear(void)
{
 Wire.beginTransmission(I2C_ADDRESS); 
 Wire.write(0xFE);           //Prefix
 Wire.write(CLEAR_SCREEN);   //Clear Display
 Wire.endTransmission();
 delay(2);                 //wait for a 1/4 second
}

void Set_Cursor_Line_1(void)
{
 Wire.beginTransmission(I2C_ADDRESS); 
 Wire.write(0xFE);         //Prefix
 Wire.write(0x45);         //Set Cursor
 Wire.write(0x00);         //
 Wire.endTransmission();
 delay(2);               //wait for a 1/4 second
}

void Set_Cursor_Line_2(void)
{
 Wire.beginTransmission(I2C_ADDRESS); 
 Wire.write(0xFE);         //Prefix
 Wire.write(0x45);         //Set Cursor
 Wire.write(0x40);         //
 Wire.endTransmission();
 delay(2);               //wait for a 1/4 second
}

void Cursor_Home(void)
{
 Wire.beginTransmission(I2C_ADDRESS); 
 Wire.write(0xFE);           //Prefix
 Wire.write(CURSOR_HOME);     //Cursor Home
 Wire.endTransmission();
 delay(2);                 //wait for a 1/4 second
}

void Cursor_Right(void)
{
 Wire.beginTransmission(I2C_ADDRESS); 
 Wire.write(0xFE);           //Prefix
 Wire.write(MOVE_CURSOR_RIGHT);     //Cursor Home
 Wire.endTransmission();
 delay(2);                 //wait for a 1/4 second
}



Pages: [1]