hello community
I share my Arduino IDE code which has a problem with the characters on the LCD that are not displayed correctly, please I ask for your help.
Hola Comunidad
Les comparto mi codigo de Arduino IDE el cual tiene un problema con lo caracteres de la LCD que no se muestran correctamente, por favor les pido su ayuda
#include <LiquidCrystal_I2C.h>
#define PIN_VRx A0
#define PIN_VRy A2
#define PIN_SW 2
int x, y;
int x_ang, y_ang;
int boton = 13;
int time = 0;
int velocidad=800;
int columna = 16;
int lectura =0;
int posicion = 1;
LiquidCrystal_I2C lcd(0x27,16,2);
byte customChaur[] = {
B01110,
B01110,
B01110,
B10101,
B01110,
B00100,
B01010,
B10001
};
byte cactus[] = {
B00000,
B00100,
B00101,
B10101,
B10111,
B11100,
B00100,
B00100
};
void setup() {
lcd.begin(16, 2);
lcd.createChar(1, customChaur);
lcd.createChar(2, cactus);
lcd.init();// inicializa la LCD
lcd.backlight();//Enciende la luz tracera
Serial.begin(9600);
pinMode( PIN_SW, INPUT_PULLUP );
}
void loop() {
// leer posición del joystick con Arduino
x = analogRead(PIN_VRx);
y = analogRead(PIN_VRy);
// mapear los valores a grados
x_ang = map( x, 0, 1023, 0, 180 );
y_ang = map( y, 0, 1023, 0, 180 );
Serial.print( "X_ang:" );
Serial.print(x_ang);
Serial.print(" ");
delay(1000);
Serial.print( "Y_ang:" );
Serial.print(y_ang);
Serial.print( " SW:");
Serial.print( digitalRead(PIN_SW) );
Serial.println();
delay(1000);
for(time=0; time<=100; time ++){//(Este ciclo for es para el nivel 1)
lcd.setCursor(9,0);
lcd.print(time);
lcd.setCursor(1,1);
lcd.write(byte(1));
columna = columna -1;
if(time==50){
lcd.clear();
delay(100);
lcd.setCursor(1,0) ;
lcd.print("Level 2");
delay(velocidad=300);
time=5;
}
if(time==100){
lcd.clear();
delay(100);
lcd.setCursor(1,0) ;
lcd.print("Level 3");
delay(velocidad=200);
time=5;
}
if(time==150){
lcd.clear();
delay(100);
lcd.setCursor(1,0) ;
lcd.print("Level 4");
delay(velocidad=300);
time=5;
}
if(columna <=0){
columna=16;
}
lcd.setCursor(columna,1);
lcd.write(byte(2));
delay(velocidad);
lcd.clear();
if(posicion == 1 && columna <=2 ){
lcd.clear();
lcd.setCursor(3,0);
lcd.print("Game Over");
delay(3000);
time=0;
}
if(analogRead(x_ang)==89){
posicion =0;
lcd.setCursor(1,posicion);
lcd.write(byte(1));
delay(100);
lcd.clear();
}
else{ posicion = 1;
}
}
}