Hola:
Intento escribir en un LCD 20x4 con protocolo I2C pero lo único que hace es encender la pantalla. No presenta los caracteres.
la biblioteca que uso está descargada de Malapartida y este es el código:
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
#include <LCD.h>
#define I2C_ADDR 0x3F // Define I2C Address where the SainSmart LCD is
#define BACKLIGHT_PIN 3
#define En_pin 2
#define Rw_pin 1
#define Rs_pin 0
#define D4_pin 4
#define D5_pin 5
#define D6_pin 6
#define D7_pin 7
LiquidCrystal_I2C lcd(I2C_ADDR,En_pin,Rw_pin,Rs_pin,D4_pin,D5_pin,D6_pin,D7_pin);
void setup()
{
lcd.begin (20,4);
// Switch on the backlight
lcd.setBacklightPin(BACKLIGHT_PIN,POSITIVE);
lcd.setBacklight(HIGH);
// Position cursor and write some text
lcd.home (); // go to the first line, first character
lcd.print("SainSmart I2C tester");
lcd.setCursor ( 0, 1 ); // go to the 2nd line
lcd.print("It's Working!");
lcd.setCursor ( 0, 2 ); // go to the third line
lcd.print("Sainsmarts docs suck");
lcd.setCursor ( 0, 3 ); // go to the fourth line
lcd.print("Nice LCD Though. ");
}
void loop()
{
}
Agradecería si a alguien le funciona me facilitase código similar al expuesto y biblioteca que usa.
Esa es la dirección que me devuelve I2C Scaner.
En esa dirección es donde enciende la pantalla pero no consigo que se visualicen los caracteres.
He probado a regular el contraste pero solo aparece un cuadrito blanco.
He probado con otras direcciones y no hace nada por eso necesito un stetch y biblioteca probados.
Que significa? Funciona o no funciona.
Somos personas de distintos países. Para mi funciona lo mismo es que SI funciona.
Dirás que hace lo mismo que con la otra inicialización?
Comencemos por la librería, cual estas usando?
Busca fmalpartida liquidCrystal y reemplaza la que tienes o ponle como extensión .old y no la uses.
Yo he usado mucho esta librería sin problemas.
Hola surbyte:
He probado así como dices con la librería de F. Malpartida en este nuevo código:
#include <LCD.h>
#include <LiquidCrystal_I2C.h>
#include <Wire.h>
// Get the LCD I2C Library here:
// https://bitbucket.org/fmalpartida/new-liquidcrystal/downloads
// Move any other LCD libraries to another folder or delete them
// See Library "Docs" folder for possible commands etc.
/*-----( Declare Constants )-----*/
/*-----( Declare objects )-----*/
// set the LCD address to 0x27 for a 20 chars 4 line display
// Set the pins on the I2C chip used for LCD connections:
// addr, en,rw,rs,d4,d5,d6,d7,bl,blpol
LiquidCrystal_I2C lcd(0x38, 2, 1, 0, 4, 5, 6, 7, 3, POSITIVE); // Set the LCD I2C address
/*-----( Declare Variables )-----*/
void setup() /*----( SETUP: RUNS ONCE )----*/
{
Serial.begin(9600); // Used to type in characters
lcd.begin(20,4); // initialize the lcd for 20 chars 4 lines, turn on backlight
// ------- Quick 3 blinks of backlight -------------
for(int i = 0; i< 3; i++)
{
lcd.backlight();
delay(250);
lcd.noBacklight();
delay(250);
}
lcd.backlight(); // finish with backlight on
//-------- Write characters on the display ------------------
// NOTE: Cursor Position: Lines and Characters start at 0
lcd.setCursor(3,0); //Start at character 4 on line 0
lcd.print("Hello, world!");
delay(1000);
lcd.setCursor(2,1);
lcd.print("From YourDuino");
delay(1000);
lcd.setCursor(0,2);
lcd.print("20 by 4 Line Display");
lcd.setCursor(0,3);
delay(2000);
lcd.print("http://YourDuino.com");
delay(3000);
// Wait and then tell user they can start the Serial Monitor and type in characters to
// Display. (Set Serial Monitor option to "No Line Ending")
lcd.setCursor(0,0); //Start at character 0 on line 0
lcd.print("Start Serial Monitor");
lcd.setCursor(0,1);
lcd.print("Type chars 2 display");
}/*--(end setup )---*/
void loop() /*----( LOOP: RUNS CONSTANTLY )----*/
{
{
// when characters arrive over the serial port...
if (Serial.available()) {
// wait a bit for the entire message to arrive
delay(100);
// clear the screen
lcd.clear();
// read all the available characters
while (Serial.available() > 0) {
// display each character to the LCD
lcd.write(Serial.read());
}
}
}
}/* --(end main loop )-- */
/* ( THE END ) */
En la definición de la LCD le paso como dirección “0x38” que es la dirección que me indica I2CScan.
Funciona en parte, ya que enciende y apaga la LCD tres veces, pero no aparece el texto.
Después abro el monitor serie y le paso un número cualquiera. El cursor cambia de posición aleatoriamente, no en orden, queda intemitente y no aparece carácter alguno.