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

Pages: [1]
1
Character LCDs / NHD-0420D3Z - Arduino I2C Address 0x28 SOLVED
« on: August 07, 2018, 02:05:55 AM »
I have a project which uses these displays and was originally based on a Stamp BS2pe. The display worked well at address 0x50 using the BS2. I now have the display working with the Arduino Uno. I have reduced the clock rate to 50kHz and made sure the pull ups are above 10k as mentioned in post https://www.newhavendisplay.com/NHD_forum/index.php/topic,8660.0.html.

I2C Scanner is reporting the display at address 0x28 which is one bit shifted from 0x50 and it seems one bit is being dropped on the wake up signal from the bus.

The display responds to commands sent to address 0x28 but not to those sent to 0x50.

Is this an Arduino issue or a display problem?

I am addressing the display directly using the Wire library.

#include <Wire.h>

byte val = 41;
byte val2 = 0xFE;
byte val3 = 0x45;
byte val4 = 0x00;
int Millis1;
int Millis2;
int Millis3;

void setup()
{
  Wire.begin(); // join i2c bus
  Wire.setClock(50000);
  Serial.begin(9600);
  Millis1 = micros();
  Millis2 = micros();
  Millis3 = (Millis2 - Millis1);//Measure time taken for the maths
}

void loop()
{
  Wire.beginTransmission(0x28); // transmit to device
                              // device address is specified in datasheet
 char myString[] = "This is the first line ";

 
 Wire.write(val2);
 Wire.write(val3);
 Wire.write(val4);
 Wire.write(myString);
 Wire.write(val);             // sends value byte
 Millis1 = micros();
 Wire.endTransmission();     // stop transmitting
 Millis2 = micros();
 Serial.print(Millis2 - Millis1 - Millis3);//Print time taken for 252 clock pulses in microseconds
 Serial.print(" - ");
 Serial.print((252000/(Millis2 - Millis1 - Millis3)));
 Serial.println("Khz");
 
  val++;        // increment value
  if(val == 84) // if reached 64th position (max)
  {
    val = 41;    // start over from lowest value
  }
  delay(500);
}

Pages: [1]