Help please, I don't know how to solve this

Idk why the number is not generated when I use the pulsator. It just create numbers each 5 seconds.

The code:

#include <Wire.h>
#include <LiquidCrystal_I2C.h>
int RNG = 0;
int puls = 13;
int stat = 1;
LiquidCrystal_I2C lcd(0x27, 16, 2);

void setup() {
 pinMode (puls, INPUT);
 Serial.begin(9600);                    
  while(!Serial);
  lcd.init();                  
  lcd.backlight();          
  lcd.print("RPSLSk");    
  delay (2000);
  lcd.clear();
  delay (1000);
   lcd.print("En honor a Pedro Meijueiro");        // Escribimos (texto de 10 caracteres)
  delay(1000);
 
  for (int pos=0; pos<26; pos++) {    // Scroll 10 posicións á esquerda
    lcd.scrollDisplayLeft();
    delay(150);
  }
  delay(1000);
  for (int pos=0; pos<26; pos++) {    // Scroll 26 posicións á dereita. (10 da palabra + 16 da pantalla)
    lcd.scrollDisplayRight();
    delay(150);
  }
  delay(1000);
  for (int pos=0; pos<26; pos++) {    // Mover ao centro da pantalla (5 da palabra +8 da pantalla)
    lcd.scrollDisplayLeft();
    delay(150);
  }
  delay(3000);
  lcd.clear();    
  delay (3000);
  lcd.clear();
}

void loop() {
  // put your main code here, to run repeatedly:


RNG = random(1,6);
stat = digitalRead(puls);

  Serial.println(RNG);
 
  byte T1 [8] = {B00010,B00010,B00010,B00001,B00001,B00000,B00000,B00000};
  byte T2 [8] = {B00000,B00000,B00000,B00000,B00000,B10001,B10001,B01010};
  byte T3 [8] = {B01000,B01000,B01000,B10000,B10000,B00000,B00000,B00000};
  byte T4 [8] = {B00000,B00000,B00000,B01110,B10001,B10001,B10001,B01110}; //TIJERA
  byte T5 [8] = {B00100,B00100,B01110,B10001,B00000,B00000,B00000,B00000};
  byte T6 [8] = {B00000,B00000,B00000,B01110,B10001,B10001,B10001,B01110};
  lcd.createChar (10, T1);
  lcd.createChar (11, T2);
  lcd.createChar (12, T3);
  lcd.createChar (13, T4);
  lcd.createChar (14, T5);
  lcd.createChar (15, T6);
  byte R1 [8] = {B00000,B00000,B00000,B00001,B00011,B00100,B00100,B00100};
  byte R2 [8] = {B00000,B00000,B11111,B00000,B00000,B10001,B01110,B10001};
  byte R3 [8] = {B00000,B00000,B00000,B10000,B11000,B00100,B00100,B00100};
  byte R4 [8] = {B00100,B00100,B00100,B00011,B00001,B00000,B00000,B00000};// ROCA
  byte R5 [8] = {B10001,B01110,B10101,B00100,B00100,B11111,B00000,B00000};
  byte R6 [8] = {B00100,B00100,B00100,B11000,B10000,B00000,B00000,B00000};
  lcd.createChar (20, R1);
  lcd.createChar (21,R2);  
  lcd.createChar (22,R3);
  lcd.createChar (23,R4);
  lcd.createChar (24,R5);
  lcd.createChar (25,R6);
  byte S1 [8] = {B01010,B10101,B10101,B10101,B10101,B10101,B10101,B10100};
  byte S2 [8] = {B00101,B01010,B01010,B01010,B01010,B01010,B01010,B10000};
  byte S3 [8] = {B00000,B10000,B10000,B10000,B10000,B10000,B10000,B10000};
  byte S4 [8] = {B10000,B10000,B10000,B01000,B01000,B00100,B00100,B00011};// SPOCK
  byte S5 [8] = {B00000,B00000,B00000,B00000,B00000,B00000,B00000,B11111};
  byte S6 [8] = {B10101,B10101,B01001,B00001,B00010,B00010,B00100,B11100};
  lcd.createChar (30, S1);
  lcd.createChar (31, S2);
  lcd.createChar (32, S3);
  lcd.createChar (33, S4);
  lcd.createChar (34, S5);
  lcd.createChar (35, S6);
  byte L1 [8] = {B00000,B00000,B00001,B00110,B01000,B10011,B10010,B10010};
  byte L2 [8] = {B01111,B10000,B00111,B01000,B10000,B00000,B00000,B00000};
  byte L3 [8] = {B11100,B00010,B10010,B11011,B10001,B01010,B00100,B00000};
  byte L4 [8] = {B10010,B10010,B10001,B01000,B00111,B00000,B00000,B00000};// LAGARTO
  byte L5 [8] = {B00000,B00000,B11110,B00001,B11100,B00010,B00001,B00000};
  byte L6 [8] = {B00000,B00100,B01010,B01010,B10010,B00100,B11000,B00000};
  lcd.createChar (40, L1);
  lcd.createChar (41, L2);
  lcd.createChar (42, L3);
  lcd.createChar (43, L4);
  lcd.createChar (44, L5);
  lcd.createChar (45, L6);
  byte P1 [8] = {B00000,B00000,B00000,B00000,B00001,B00010,B00010,B00010};
  byte P2 [8] = {B00111,B01000,B10110,B10011,B00000,B10000,B01110,B00011};
  byte P3 [8] = {B11110,B00001,B00001,B10001,B00001,B00010,B00100,B01000};
  byte P4 [8] = {B00010,B00101,B01000,B01010,B01011,B01000,B01000,B00111};// PAPEL
  byte P5 [8] = {B00000,B11000,B01110,B00000,B10000,B11001,B00001,B11110};
  byte P6 [8] = {B10000,B10000,B10000,B10000,B10000,B00000,B00000,B00000};
  lcd.createChar (50, P1);
  lcd.createChar (51, P2);
  lcd.createChar (52, P3);
  lcd.createChar (53, P4);
  lcd.createChar (54, P5);
  lcd.createChar (55, P6);
 
if (stat == 1){
random(1,1);
delay(500);

if
(RNG == 1){

  lcd.print((char)10);

  lcd.print((char)11);

  lcd.print((char)12); // Si sale 1 se imprimirá tijeras

  lcd.print((char)13);

  lcd.print((char)14);

  lcd.print((char)15);
}
if
  (RNG == 2){
  lcd.print((char)20);  
  lcd.print((char)21);  
  lcd.print((char)22);  // Si sale 2 se imprimirá piedra
  lcd.print((char)23);  
  lcd.print((char)24);  
  lcd.print((char)25);  

}
if
  (RNG == 3){
  lcd.print((char)30);
  lcd.print((char)31);  
  lcd.print((char)32);  // Si sale 3 se imprimirá spock
  lcd.print((char)33);  
  lcd.print((char)34);  
  lcd.print((char)35);  

}
if
  (RNG == 4){
  lcd.print((char)40);
  lcd.print((char)41);  
  lcd.print((char)42);  // Si sale 4 se imprimirá lizard
  lcd.print((char)43);  
  lcd.print((char)44);  
  lcd.print((char)45);  

}
if
  (RNG == 5){
  lcd.print((char)50);
  lcd.print((char)51);  
  lcd.print((char)52);  // Si sale 5 se imprimira papel
  lcd.print((char)53);  
  lcd.print((char)54);  
  lcd.print((char)55);  

}
}
else{
delay (10000);
lcd.clear();
}
}

What are you trying to demonstrate in your tutorial?

Why not put the character creation code into the setup function?
Can you really create that many characters?
Which LCD are you using?
Most basic LCDs are limited to eight, if I recall correctly.

I just want help.
I'm using a QAPASS 1602A 16x2

@pablobr,

Your topic was moved to its current location as it is more suitable.

Could you also take a few moments to Learn How To Use The Forum.

It will help you get the best out of the forum in the future.

Thank you

you can't have that many custom chars as said by

I think you can continuous upload new custom characters...
But the LCD that I used needed like 16 digital ouputs or so if you wanted to use that feature...

We just need more information from you to be able to help.

What is the display-controller-type of your LC-display?

writing "using a QAPASS 1602A 16x2"
is not enough information to clearly know what LCdisplay-Controller-Chip your display is using.

For looking up how many custom characters your particular LCDisplay-controller-chip can hold it is nescessary to what exact type of controller-chip this is.

Most of them will only hold 8 customised characters like mentioned above.
So one way is to define the characters "on the fly"
another solution would be to use a different display that suits better to oyur application that seem to require a lot of customised characters.

An OLED-Display or a TFT-Display with pixels will allow to show any kind of things as you can control each pixel individually.

For suggestions how to solve this problems you would have to describe your project in detail.

best regards Stefan

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.