I have tried to find the answer to this question through the search function and I haven't found anything. I'm 100% certain I'm not asking it the right way, but maybe someone will read this and be able to help me out.
I'm new to programming, and I'm not great at it. However...I need to print a character to a random location on the lcd. That's easy enough.
lcd.setCursor(random(0,16), random(0,2));
Now...what I want to do is to create a variable for the row and column.
int randRow = random(0,16);
int randCol = random(0,2);
Then the command would be...
lcd.setCursor(randRow,randCol);
BUT, every time I do that, the lcd sets the cursor to (7,1) and it just stays there.
Sorry, I didn't include the whole sketch the first time around. Just to make sure i'm making sense, if I use (random(0,16), random(0,2)) for the set cursor command it works. It's this version here that does not.
#include <LiquidCrystal.h>
int randRow = (random(0,16));
int randCol = (random(0,2));
LiquidCrystal lcd(13, 12, 11, 10, 9, 8);
And what Kenny posted and then removed made sense as well. I wasn't thinking it all the way through. Basically, by setting the integers to a random number in the setup, it did the random selection once and then THAT number was what would be used down in the loop.
So...is the fact that the cursor would always place into the (7,1) spot a factor of the default pseudorandom code?
Thank you, to both of you. You got me through my block. I spent too much time trying to do the same thing over and over...couldn't see the forest for the trees.
Yeh I removed it because it was answered at the same time. The funny thing about random is that it is not really that random, if you start it at the same time in the same place you will find that the outcome is the same. So if you really want something that is absolutely random, that is not really the way. If you find it interesting, look up how random Math.random() is in C, the discussions and solutions are really nice to learn from.