16 X 2 LCD with PCF 8574 (without using I2C library)


hello friends, here using lcd 8574 without lcd library . address of 8574 set 32 (0x20) .
p0 connected en of lcd , p1 rs , p2-p5 connected d4-d7 of lcd . code have written (which bit lengthy ) not getting output. contrast moderate that's not problem sure.
can guys me out of it...... :smiley-roll-sweat: :~
quote

#include<wire.h>
int add=32;
int x=1;
byte command,data;
byte string[13]={'a','w','e','s','o','m','e',' ','r','a','h','u','l'};
void setup()
{
wire.begin();
wire.begintransmission(add);
lcd_initialise();
}
void loop()
if(x)// wanted run once
  {
    for(int i=0;i<=11;i++)
    lcd_display(string);
  }
x=0;
}
void lcd_initialise()
{
  command=0x38;//init lcd 2 line 5x7 matrix
  lcd_command(command);
  command=0x0e;//lcd on cursor on
  lcd_command(command);
  command=0x01;//clear lcd
  lcd_command(command);
  command=0x06;//shift cursor right
  lcd_command(command);
  command=0xc0;//cursor @ line 1 , position 1
  lcd_command(command);
}
void lcd_display(byte data1)
{
   byte temp;
  temp=0xf0 && data1;
  temp=temp>>2;
  temp=temp^0x02;
  wire.begintransmission(add);
  wire.write(temp);// rs equals 1 data , en equal zero
  // en=1 , send again again en =0
  temp=temp^0x01;// exoring en becomes 1
  wire.write(temp);
  delay(10);// delay in between
  temp=temp^0x01;// again exoring en becomes 0
 // , data latched
  wire.write(temp);
  // same repeated lower nibble
  delay(10);
  temp=0x0f && data1;
  temp=temp<<2;
  temp=temp^0x02;// rs made 1 data reg
  //and en 0 default
  wire.write(temp);
  temp=temp^0x01;// en made 1
  wire.write(temp);
  delay(10);// delay in between
  temp=temp^0x01;// en made 0 data latched
  wire.write(temp);
  delay(50);
 wire.endtransmission();
}
void lcd_command(byte command1)
{
  byte temp;
  temp=0xf0 && command1;
  temp=temp>>2;
  wire.begintransmission(add);
  wire.write(temp);// rs , en both equal zero
  // en=1 , send again again en =0
  temp=temp^0x01;// exoring en becomes 1
  wire.write(temp);
  delay(10);
  temp=temp^0x01;// again exoring en becomes 0
 // , data latched
  wire.write(temp);
  // same repeated lower nibble
  delay(10);
  temp=0x0f && command1;
  temp=temp<<2;
  wire.write(temp);
  temp=temp^0x01;
  wire.write(temp);
  delay(10);
  temp=temp^0x01;
  wire.write(temp);
  delay(500);
 wire.endtransmission();   
}

your code difficult read because have used 'quote' tags instead of 'code' tags, please go edit post fix this.

i have not thoroughly gone through code few things stand out.

are sure using pcf8574 , not pcf8574a has different address?

how know contrast 'moderate'?  if not sure of setting extreme setting (0 volts) on pin 3 option.

it idea use 'initialization instruction' sequence recommended in hd44780 datasheet rather incorrect 1 used in lot of examples floating around internet.  follow lcd addressing link @ http://web.alfredstate.edu/weimandn more information.  you find programming examples there.

instead of using "{ if(x)//wanted run once  ..." why don't put relevant code in setup(), that's setup() for?

the lcd initialization sequence should in setup().  change alone may fix program , should done first.

this (command=0xc0;//cursor @ line 1 , position 1) putting cursor @ line 1 , position 0 if count 0 - 9 , putting cursor @ line 2 , position 1 if count 1 - 10.   isn't basic problem since address (0x40) visible on displays know of.

that should keep out of trouble while.


don


Arduino Forum > Using Arduino > Displays > 16 X 2 LCD with PCF 8574 (without using I2C library)


arduino

Comments

Popular posts from this blog

VIDIOC_S_FMT error 16, Device or resource busy - Raspberry Pi Forums

using a laptop skeleton to build a pi laptop - Raspberry Pi Forums

Forum for Joomla? - Joomla! Forum - community, help and support