This does not do anything (except for wasting cpu cycles )
To get a value in the array, use e.g.
for(int i=0; i<4; i++){
array1[i] = i;
}
Not quite what you want but it's a start
for(int j=0;j<4;j++){
lcd.setCursor(0,0);
lcd.print(array1[j]);
}
This will at high speed display the values in the array at position 0,0; your eye will probably not be able to follow and only see the last number displayed.
is it possible to do that?
Yes. How is the user going to enter the numbers? Keypad, serial port, ... ?
Example 4 of Robin2's serial tutorial shows how to read in an integer from the monitor (although you didn't say if input is from the monitor or elsewhere).
In fact, even better than example 4, is example 5, and enter one line as <int,int,int,int,int>
// 5 integers into an array
// BASED ON Example 5 - Receive with start- and end-markers combined with parsing
// https://forum.arduino.cc/index.php?topic=396450
const byte numChars = 32;
char receivedChars[numChars];
char tempChars[numChars]; // temporary array for use when parsing
// variables to hold the parsed data
int integerFromPC[5];
boolean newData = false;
//============
void setup() {
Serial.begin(9600);
Serial.println("Enter 5 integers in this style <int,int,int,int,int> ");
Serial.println();
}
//============
void loop() {
recvWithStartEndMarkers();
if (newData == true) {
strcpy(tempChars, receivedChars);
// this temporary copy is necessary to protect the original data
// because strtok() used in parseData() replaces the commas with \0
parseData();
showParsedData();
newData = false;
}
}
//============
void recvWithStartEndMarkers() {
static boolean recvInProgress = false;
static byte ndx = 0;
char startMarker = '<';
char endMarker = '>';
char rc;
while (Serial.available() > 0 && newData == false) {
rc = Serial.read();
if (recvInProgress == true) {
if (rc != endMarker) {
receivedChars[ndx] = rc;
ndx++;
if (ndx >= numChars) {
ndx = numChars - 1;
}
}
else {
receivedChars[ndx] = '\0'; // terminate the string
recvInProgress = false;
ndx = 0;
newData = true;
}
}
else if (rc == startMarker) {
recvInProgress = true;
}
}
}
//============
void parseData() { // split the data into its parts
char * strtokIndx; // this is used by strtok() as an index
strtokIndx = strtok(tempChars, ","); // get the first integer
integerFromPC[0] = atoi(strtokIndx); // convert this part to an integer
for (byte i = 1; i < 5; i++)
{
strtokIndx = strtok(NULL, ","); // get the second and subsequent integer
integerFromPC[i] = atoi(strtokIndx); // convert this part to an integer
}
}
//============
void showParsedData() {
Serial.print("Array values: ");
for (byte i = 0; i < 5; i++)
{
Serial.print(integerFromPC[i]); Serial.print(" ");
}
Serial.println(" ");
}