Hello friends, I am here using a LCD with 8574 but without any LCD library . Address of 8574 is set to 32 (0x20) .
P0 is Connected to EN of LCD , P1 to RS and P2-P5 are connected to D4-D7 of LCD . With code I have written (which is a bit lengthy ) I am not getting any output. Contrast is moderate so that's not a problem for sure.
Can you guys help me out of it......
:~
#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 to run this only 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 at line 1 and 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 one for data and en equal zero*
- // en=1 and send again then 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*
- // and data will be latched*
- Wire.write(temp);*
- // same to be repeated for lower nibble*
- delay(10);*
- temp=0x0F && data1;*
- temp=temp<<2;*
- temp=temp^0x02;// rs made 1 for data reg*
- //and en is 0 as default*
- Wire.write(temp);*
- temp=temp^0x01;// en made 1*
- Wire.write(temp);*
- delay(10);// some delay in between*
- temp=temp^0x01;// en made 0 to get 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 and en both equal zero*
- // en=1 and send again then again en =0*
- temp=temp^0x01;// exoring en becomes 1*
- Wire.write(temp);*
- delay(10);*
- temp=temp^0x01;// again exoring en becomes 0*
- // and data will be latched*
- Wire.write(temp);*
- // same to be repeated for 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(); *
}
[/quote]
LCD_i2c.ino (2.02 KB)