I've written a little program that stores input from the serial console into an array
named LCDarray[rows][cols] and prints with the LiquidCrystal.h library.
I want the function below to initialize a new array of int[MAX], shuffle that array,
and then select the cursor position and array position of LCDarray[][]
with the values inside the int[] array elements.
I understand I haven't seeded it, I'm working on getting it working for now
For my 'y' value I just alternate between 0 and 1. (random enough for now)
The function prints a (seemingly) random amount of the array LCDarray[][] and I'm wracking my brain trying to figure it out.
int randomWriteArray2(char LCDarray[][cols]){
int k=0, r=0, temp=0, orderCols[MAX];
//initialize array as "0"..."'cols-1'0"..."'cols-1'"
for(k=0;k<MAX;k++)orderCols[k]=(k%cols);
//randomize loop
for (k=0;k<MAX;k++){
//pick random number from 0-MAX
r=random(MAX);
//hold element k as temp
temp=orderCols[k];
//swap in randomly selected element
orderCols[k]=orderCols[r];
//replace randomly selected element with temp
orderCols[r] = temp;
}
//LCD write loop
for(k=0;k<MAX;k++){
lcd.setCursor(orderCols[k],k%cols);//move cursor to xy
lcd.write(LCDarray[k%cols][orderCols[k]]);//write LCDarray[y,x]
delay(100);//for the random look effect
}
return 0;//this is the numChar counter, set to 0 so write functions will not write
}
In the hopes anyone could help I commented the crap out of it.
The LCDarray is properly loaded (I checked) and the orderCols[] array is properly shuffled (enough for me anyways) with no repeated numbers or lost numbers(0 to 15 x2), the damn thing just won't write to the LCD properly.