I'm trying to test 595 in 2 Wire mode with backlight control and I'm struggling a little.
I've been over my wiring time and time again and I'm sure it's right. I've followed the ASCII wiring in the LiquidCrystal_SR2W.h file
Something must be working as I can control the backlight on and off. I then have two screens of test text and an animation for testing. All I'm getting displayed is random characters, although I can see parts of my text in it at times.
The display updates at the times that I would expect it to, and seems to do the animation, albeit it is all pseudo garbage characters, rather than what it should be displaying.
One thing that is also confusing me when I look at the _SR and _SR2W code is that they look to me like they don't use the same wiring.
For SR2W I have Bit 0 (Pin 15) connected to BL control. Bit 1 (Pin 1) is LCD RS. Bit 2-5 (Pins 2 - 5) is LCD D4-D7. Bit 6 (Pin 6) is one end of the diode. The other end of the diode is connected to E, with a 1k resistor between E and Data. Clock is onto Clock and Latch.
The thing that is confusing is that _SR seems to be saying that RS, D4-D7 and the diode are all one bit on.
I understand that using the 595 as non latching means bits are all out by one, but the _SR seems to be referring to the same 595 wiring.
Code is below, wiring is a bit of a mess as it's thrown together on a breadboard. If it's not possible to make any suggestion as to why everything seems to work except for bad characters then I'll rip it apart tomorrow and put back together tidily for some pictures.
My test sketch:-
#include <Wire.h>
#include <LCD.h>
#include <LiquidCrystal_SR2W.h>
const int BACKLIGHT_PIN = 29; // If using ext/pwm backlight pin
// Set the LCD constructor
LiquidCrystal_SR2W lcd1(27, 28, NEGATIVE);
// Creat a set of new characters
const uint8_t charBitmap[][8] = {
{ 0xc, 0x12, 0x12, 0xc, 0, 0, 0, 0 },
{ 0x6, 0x9, 0x9, 0x6, 0, 0, 0, 0 },
{ 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0, 0x0 },
{ 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0, 0x0 },
{ 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0, 0x0 },
{ 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0, 0x0 },
{ 0x0, 0x0, 0x0, 0x6, 0x9, 0x9, 0x6, 0x0 },
{ 0x0, 0x0, 0x0, 0xc, 0x12, 0x12, 0xc, 0x0 }
};
void setup()
{
int charBitmapSize = (sizeof(charBitmap ) / sizeof (charBitmap[0]));
// Switch on the backlight if using the hardware pin
pinMode(BACKLIGHT_PIN, OUTPUT);
digitalWrite(BACKLIGHT_PIN, LOW);
lcd1.begin(16,2); // initialize the lcd for a 16x2 panel
lcd1.setBacklight(1); // switch on the backlight if being controlled via SR
for ( int i = 0; i < charBitmapSize; i++ )
{
lcd1.createChar ( i, (uint8_t *)charBitmap[i] );
}
lcd1.home(); // set LCD cursor to the home position
lcd1.print(F(" Hello, Testing "));
lcd1.setCursor(0, 1); // set cursor to the first character of the second line
lcd1.print(F(" SR2W Backpack "));
delay(2000);
lcd1.home(); // set LCD cursor to the home position
lcd1.print(F(" Using HC595 "));
lcd1.setCursor(0, 1); // set cuirsor to the first character of the second line
lcd1.print(F(" Shift Register "));
delay(2000);
delay(4000);
}
void loop()
{
lcd1.home();
// Do a little animation by writing to the same location
for ( int i = 0; i < 2; i++ )
{
for ( int j = 0; j < 16; j++ )
{
lcd1.print (char(random(7)));
}
lcd1.setCursor ( 0, 1 );
}
delay (500);
}