hello,
im trying to display an array on lcd after getting it from the user as input
i want to get 4 digits as input, put them on the array ( temp[] ) after that display the hole array on the lcd
here is the code for the array input (on void loop)
char temp[] = {} ;
i=0;
while(i<4)
{
key = customKeypad.waitForKey();
if(key != NO_KEY)
{
temp[i]=key;
lcd.print(key);
}
i++;
delay(40);
}
i had no problems with the input code and it was working as it should, but after i wrote the code of displaying the program stopped getting key as input at 1=2 , ended the while and printed a symbol i don't know
i wrote this for displaying
lcd.clear();
delay(650);
lcd.print(temp[i]);
so can someone help me with this problem please ??
i wrote the code of displaying the program stopped getting key as input at 1=2 , ended the while and printed a symbol i don't know
I do not know what that means. Can you post the code that you are talking about and a picture of the output on the LCD?
lcd.clear();
delay(650);
lcd.print(temp[i]);
That code will print one element of the temp array.
Is the total code a secret? It's more or less impossible to give any advice on those pices of code.
char temp[] = {} ;
A zero element array?
This shows how to print an array to an LCD using a for loop.
#include <hd44780.h>
#include <hd44780ioClass/hd44780_pinIO.h> // Arduino pin i/o class header
const byte rs = 12, en = 11, db4 = 4, db5 = 5, db6 = 6, db7 = 7;
hd44780_pinIO lcd(rs, en, db4, db5, db6, db7);
byte temp[] = {1, 2, 3, 4};
// LCD geometry
const int LCD_COLS = 16;
const int LCD_ROWS = 2;
void setup()
{
lcd.begin(LCD_COLS, LCD_ROWS);
lcd.print("Hello, World!");
lcd.setCursor(0, 1); //second row
// use a for loop to print the contents of an array
for (byte n = 0; n < sizeof(temp) / sizeof(temp[0]); n++)
{
lcd.print(temp[n]);
lcd.print(" ");
}
}
void loop()
{ } // everything happens in setup()
sorry for not posting the total code sir but its about 800 lines i cant post it here so i have just posted the lines related to the topic i want


My answer is too long to write here.
Sorry.
From the forum guidelines:
Post a complete sketch (program code)! If you don't you waste time while people ask you to do that. However, with coding problems, if possible post a "minimal" sketch that demonstrates the problem - not hundreds of lines of code. If the problem goes away in the minimal sketch, it wasn't where you thought it was.
If you will not write a minimal sketch you can attach the code if it is over the 9000 character limit. See #8 in the linked guidelines.
thank you all, i have solved it
i have changed the array to be
char temp [] = {0,0,0,0};
and made a for loop for the displaying line to be
for ( i = 0 ; i<4 ; i++ )
{
lcd.print(temp[i]);
}
now its working correctly, and sorry for not posting the total code again i know it may be rude for some of you but my problem wasnt worth it to post the total code
sorry for you all and thank you again
