I'm making an Arduino print out 1 random number on an LCD screen. I am so far unsuccessful. This is my code so far, and I am not smort enough to figure out what's wrong with it. Can anybody help?
for ( i=0; i < sizeof(raw.b); ++i )
{
EEPROM.write( i, raw.b[i] );
}
reseedRandom();
}
// gives the display a name lcd that can be used
// 16, 2 = 16 spaces and 2 lines
// 0x27 = default address of the display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup()
{
// needs to be at the start of the screen commands
// try lcd.init()
lcd.begin();
// turns the backlight of the LCD off
lcd.backlight();
// clears the contents of the screen
lcd.clear();
// set the position that writing will start
// 4 = 4 spaces along
// 0 = line 1, 1 = line 2
lcd.setCursor(4,0);
}
void loop(){
lcd.print(reseedRandom());
delay(750); // Delay a little
Hello, do yourself a favour and please read How to get the best out of this forum and modify your post accordingly (including code tags and necessary documentation of your ask).
You need an lcd.print(); to put something on the display.
You have 'reseedRandom()' calling itself so it will never exit. Eventually it will run out of memory and crash.
If you want a random number you need a source of randomness. Most examples read an analog input that is floating. Not a great source but better than a crashing program. Get rid of your 'reseedRandom()' function. Call 'randomSeed(analogRead(A0)); in setup() and lcd.print(random()); in loop().
Please read the post at the start of any forum , entitled "How to use this Forum".
Why have you got references to primes and eeproms.
Can I suggest you just get the random number generator working through the IDE serial monitor before thinking about LCD and EEPROMS.
What is your ultimate aim?
This link shows you how to generate a random number and seed it.
There is even sample code you can use.
It looks like you have generated a lump of code and are now trying to debug it.
Develop your code in stages, getting each stage working before going to the next.